Shipment.all() and Transaction.all() only returns 3 results
XinyueZhang831 opened this issue · 6 comments
Hi all,
I was trying to use the API to export the Shipment data. No matter I used Transaction.all() or Shipment.all() with a two month time period, there always 3 return info. Is there anyway I can export all shipment information for the recent two months?
Thanks
Max date range of 90 days for shipments from API documentation on shipments
https://goshippo.com/docs/reference#shipments-list
If you have the tracking number you should be able to get the transaction object_id via the /tracks endpoint and then grab additional information about the shipment via the /transactions/ -> https://goshippo.com/docs/reference#transactions-retrieve
Max date range of 90 days for shipments from API documentation on shipments
https://goshippo.com/docs/reference#shipments-list
If you have the tracking number you should be able to get the transaction object_id via the /tracks endpoint and then grab additional information about the shipment via the /transactions/ -> https://goshippo.com/docs/reference#transactions-retrieve
Thanks for replying!
Yes, I want to get the Shipment data from recent 2 months which is 60 days (from 2 months ago til today), so I think the time range is fine.
I don't have tracking number or any other parameter. The parameters I can give are the time period. I used object_created_gte and object_created_lte in my code:
shippo.Transaction.all( object_created_gte="2020-08-27", object_created_lte = "2020-10-27")
or
shippo.Shipment.all( object_created_gte="2020-08-27", object_created_lte = "2020-10-27")
I don't understand why in the return info {"next": "https://api.goshippo.com/v1/transactions/?object_created_gte=2020-08-27&object_created_lte=2020-10-27&page=2"}, there is a page=2, and I am not sure if this is the issue or not, but I cannot do anything with it since it is from the encode and decode in requester.
All three return info are the shipment/transaction data on 10/27.
What I want to do is exporting the shipment data, and the data from the API return should be the same as the data I get from Shipments page on the website but in Json format.
Thanks again!
Keep in mind that this python-client is just an wrapper around our REST API. That URL is just the endpoint where the 2nd page of results is located (there might be a page 4, page 5, page .... )
You could think of this response as the pages 1..10 on a search engine (i.e google). I'll try and dig into this a little more tomorrow morning. In the meantime you can use the python requests library to hit that page 2.
To accomplish this do a GET on that next key value which is the url of the next results && provide the authorization header to use the API:
Authorization: ShippoToken <YOURSHIPPOTOKEN>
import requests
headers = {}
headers['Authorization'] = "ShippoToken <YOURSHIPPOTOKEN>"
r = requests.get("https://api.goshippo.com/v1/transactions/?object_created_gte=2020-08-27&object_created_lte=2020-10-27&page=2",headers=headers)
print(r.content)
The docs on the requests custom header can be located at:
https://requests.readthedocs.io/en/master/user/quickstart/#custom-headers
- Just an aside......you might be better off exporting the data from the website and using python/sed/awk/csvcut to get the information you want rather than this particular API endpoint.
Keep in mind that this python-client is just an wrapper around our REST API. That URL is just the endpoint where the 2nd page of results is located (there might be a page 4, page 5, page .... )
You could think of this response as the pages 1..10 on a search engine (i.e google). I'll try and dig into this a little more tomorrow morning. In the meantime you can use the python requests library to hit that page 2.
To accomplish this do a GET on that next key value which is the url of the next results && provide the authorization header to use the API:
Authorization: ShippoToken <YOURSHIPPOTOKEN>
import requests headers = {} headers['Authorization'] = "ShippoToken <YOURSHIPPOTOKEN>" r = requests.get("https://api.goshippo.com/v1/transactions/?object_created_gte=2020-08-27&object_created_lte=2020-10-27&page=2",headers=headers) print(r.content)The docs on the requests custom header can be located at:
https://requests.readthedocs.io/en/master/user/quickstart/#custom-headers
Thanks a lot for your reply! And yes, I will check the header tomorrow as well.
I need to update some data on google sheets so I want to automate the whole process and make a timer for my code to run on certain time everyday. I used Selenium to interact with most websites and database to get the data I need, but Shippo has recaptcha which doesn't allow me to login, so I am try to get the data from API. If at this point, it is better to use the website rather than API, then I will manually export data from website which is fine :)
I understand the idea of page and I saw there is a parameter page= in all() , but if I gave any int (I tried 1 and 3, page = 1), the API runs into error.
Thanks again!
Keep in mind that this python-client is just an wrapper around our REST API. That URL is just the endpoint where the 2nd page of results is located (there might be a page 4, page 5, page .... )
You could think of this response as the pages 1..10 on a search engine (i.e google). I'll try and dig into this a little more tomorrow morning. In the meantime you can use the python requests library to hit that page 2.
To accomplish this do a GET on that next key value which is the url of the next results && provide the authorization header to use the API:
Authorization: ShippoToken <YOURSHIPPOTOKEN>
import requests headers = {} headers['Authorization'] = "ShippoToken <YOURSHIPPOTOKEN>" r = requests.get("https://api.goshippo.com/v1/transactions/?object_created_gte=2020-08-27&object_created_lte=2020-10-27&page=2",headers=headers) print(r.content)The docs on the requests custom header can be located at:
https://requests.readthedocs.io/en/master/user/quickstart/#custom-headers
Good morning,
I just checked the header with different page numbers then I found there is more than 200 page records for the data in my time period... if I request with different page, it will take too long time to do it...I guess I have to export from website then.