Foursquare API: sort checkins by oldest first - foursquare

So I have some code that's been running for a good ~6 months or so, and I don't think I've changed anything relevant to this (famous last developer words), but Foursquare has started returning what I'd consider to be incorrect responses.
I'm trying to hit the checkins endpoint for yourself: i.e., /v2/users/self/checkins. My options params are as follows:
params = {
v: '20160622',
afterTimestamp: start_time,
sort: 'oldestfirst',
limit: 250
}
This all seems to be fine and dandy, but Foursquare is only seemingly sub-sorting newest-first. In other words, I'm asking Foursquare for "show me all of the checkins, sorted by the oldest" and it's returning stuff from today. Especially with afterTimestamp: 0, I expect that it should show me the oldest checkin associated with my account: namely, my very first checkin of all time.
So, to recap: how do I query the API so that I can find my oldest checkins first? From what I can tell, this should be properly returning the correct checkins.
Cheers!

I was playing around with this endpoint and it appears to sort results after they're extracted from "most recent". So in your case it's taking the most recent 250 checkins then sorting them by oldest first.
To get your first checkin ever you can look at the count of checkins that gets returned then offset by that amount. After you've got your first checkin you can work forwards with the afterTimestamp parameter.

Related

GetMyeBaySelling API does not return Unsold items even though they exist

Please bear with me because I'm new to eBay APIs but basically I'm trying to:
Get a list of item IDs which are Active
Get a list of item IDs which are Unsold
So the problem is pretty straightforward and I'm currently using the GetMyeBaySelling API call with an XML input that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<GetMyeBaySellingRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>{eBayAuthToken}</eBayAuthToken>
</RequesterCredentials>
<DetailLevel>ReturnAll</DetailLevel>
</GetMyeBaySellingRequest>
Again, very simple. I understand that I will get the list of all Active items, the list of all Unsold/Sold items, etc. because I've set the <DetailLevel> field to ReturnAll in the input XML above
The problem is that for some reason, for one account that I'm testing this call on, it doesn't return the list of unsold items, as in, it doesn't return the container in the XML response, I'm talking about this one:
<UnsoldList> .... </UnsoldList>
This is weird because that one particular eBay account has more than 20 unsold items in it
Now this is where things get really weird, if I tested the API call on other eBay accounts, it works just fine and returns the list of all Unsold items with no problem 😕
Did I do something wrong here or is there some kind of bug in this eBay API call?
SOLVED!
It turns out that we have to specify
<DurationInDays>{numberOfDays}</DurationInDays>
Where {numberOfDays} is an integer value which represents how far back in the past do the unsold listings we want to extract have to be?
In this case, we can specify 60, which is the maximum number of days accepted by the GetMyeBaySelling API to indicate that we want all unsold listings which ended within the past 60 days.
So what happened was that on this one particular account, all of the unsold listings ended on 5th of December 2020. Whatever the default {numberOfDays} for DurationInDays value set by eBay is, it's clearly not big enough to cover these listings which ended on 5th of December 2020. Hence, by specifying it to 60 days, I got all of the unsold listings just fine :)
So for whoever out there who's facing a similar problem, remember this field, it could very well fix the problem that you have (if it's anything similar to mine).

Foursquare api doesn't return correct checkins information

I was tested foursquare api to use it in future projects and faced a strange problem.
I will explain it in example.
You check in via Swarm app to the place 1 and call venue here now endpoint
https://api.foursquare.com/v2/venues/559bac8f498effd9368131f6/herenow?v=20160606&oauth_token=<token>
you receive correct data, your user is displayed in items array field
"response":{"hereNow":{"count":2,"items":[{"id":"583ede91a36ecd3aeee51647","createdAt":1480515217,"type":"checkin","timeZoneOffset":120,"user":{"id":"355625527","firstName":"Dima","gender":"male","relationship":"self","photo":{"prefix":"https:\/\/irs0.4sqi.net\/img\/user\/","suffix":"\/blank_boy.png","default":true}},"likes":{"count":0,"groups":[]},"like":false},{"id":"583ede0a02b60e59094ddbc5","createdAt":1480515082,"type":"checkin","timeZoneOffset":120,"user":{"id":"43963436","firstName":"Ayhan","lastName":"B","gender":"male","photo":{"prefix":"https:\/\/irs0.4sqi.net\/img\/user\/","suffix":"\/43963436-UWAYC333GLM2YQ4H.jpg"}}}]}}
Then you check in to place 2 and call same endpoint. The check in data is correct, your user is in items array.
But when you check in back to place 1, your user are not included in items array
"response":{"hereNow":{"count":1,"items":[{"id":"583ede0a02b60e59094ddbc5","createdAt":1480515082,"type":"checkin","timeZoneOffset":120,"user":{"id":"43963436","firstName":"Ayhan","lastName":"B","gender":"male","photo":{"prefix":"https:\/\/irs0.4sqi.net\/img\/user\/","suffix":"\/43963436-UWAYC333GLM2YQ4H.jpg"}}}]}}
Instead foursquare thoughts that you are still checked in to place 2.
Also when you check in recent endpoint it will return that your recent check in is to place 1
"response":{"recent":[{"id":"583ee16ed8b0ed757138ec10","createdAt":1480515950,"type":"checkin","timeZoneOffset":120,"user":{"id":"355625527","firstName":"Dima","gender":"male","relationship":"self","photo":{"prefix":"https:\/\/irs0.4sqi.net\/img\/user\/","suffix":"\/blank_boy.png","default":true}},"venue":{"id":"559bac8f498effd9368131f6","name":"Львiвськi пляцки","contact":{"phone":"0936567878","formattedPhone":"093 656 7878","facebook":"288574604603052","facebookUsername":"lvivskipljacky","facebookName":"Львівські пляцки"},"location":{"address":"вул. Богдана Хмельницького, 10","lat":50.44546701910413,"lng":30.51702892776601,"labeledLatLngs":[{"label":"display","lat":50.44546701910413,"lng":30.51702892776601}],"postalCode":"01001","cc":"UA","city":"Kyiv","state":"Kyiv City","country":"Ukraine","formattedAddress":["вул. Богдана Хмельницького, 10","Kyiv, 01001"]},"categories":[{"id":"4bf58dd8d48988d16a941735","name":"Bakery","pluralName":"Bakeries","shortName":"Bakery","icon":{"prefix":"https:\/\/ss3.4sqi.net\/img\/categories_v2\/food\/bakery_","suffix":".png"},"primary":true}],"verified":false,"stats":{"checkinsCount":2782,"usersCount":1890,"tipCount":75},"url":"http:\/\/www.fest.lviv.ua\/uk\/restaurants\/lvivskipljacky\/","allowMenuUrlEdit":true,"beenHere":{"unconfirmedCount":0,"marked":false,"lastCheckinExpiredAt":0},"specials":{"count":0}},"source":{"name":"Swarm for Android","url":"https:\/\/www.swarmapp.com"},"photos":{"count":0,"items":[]},"posts":{"count":0,"textCount":0},"likes":{"count":0,"groups":[]},"like":false,"comments":{"count":0},"isMayor":false}]}
Did anyone also face this problem too? Or does foursquare api have some limitation for check-ins? I searched though web about it, but cannot find any useful information
A user will show in the venue "Here Now" for 3 hours after they checkin OR until they checkin at another venue. In your example, a user will not appear in Place 1s "here now" if their checkin pattern is Place 1 -> Place 2 -> Place 1. I'm not sure if this is a bug or done intentionally as a quality control.

GitHub API - stars, get the date then star is created

The GitHub API provides functionality to get stared items sorted by created date. But, I can't find a possibility to get this date.
Only three date-type fields are present in the response:
created_at: '2013-06-13T21:10:36Z',
updated_at: '2013-06-18T07:45:56Z',
pushed_at: '2013-06-17T16:52:44Z',
create_at here is always that date the repository created, not star. updated_at does not give the right information either.
On the GitHub site, if you check your stars, data is sorted properly and the correct time span is rendered. But it looks like the API misses that information.
That gist clearly show, that data returned "sorted", but created_at is wrong.
This can be done in the GitHub API v3 by adding the header:
Accept: application/vnd.github.v3.star+json
see here:
https://developer.github.com/v3/activity/starring/#alternative-response-with-star-creation-timestamps-1
https://developer.github.com/v3/activity/starring/#alternative-response-with-star-creation-timestamps
There is absolutely no way to get this information from the API. Your best chance of getting it is going through events either on the repository or each user that has starred the repository and that could take tons of parsing because the events could be in the thousands. The number of API calls to do so would be immense.

Colleting a neighborhood in foursquare

im making a app in using the Foursquare API, using their API i can get some places in a neighborhood.
I'm using one like that:
https://api.foursquare.com/v2/venues/explore
?ll=40.7,-74
&limit=50
&venuePhotos=1
Using that API i can take 50 venues around my point, but how can I take more others venues like a second page of that?
You can use the "offset" parameter to query for subsequent pages of results. For example, to get the second page, you would supply "offset=50" to indicate skipping the first 50 results.

Instagram: Get photos from a tag after a specified photo

I'm working on an instagram scraper for something and I'm trying to figure out if it's possible to get all photos for a tag that have an id or timestamp later than the last one I have.
The instagram API docs are useless in that they don't have any real info on pagination (which I presume I'll have to abuse).
Does anyone have any ideas?
I've been slogging through the Instagram API for the last couple of days so here's my 2 cents worth:
As far as I can see it if you call the api with /tags/tag-name/media/recent it only return a list if items. If the amount exceeds about 25 you have to make another request with the pagination value returned in the previous request.
In order to gain some control I am initially iterating through all images and storing the results (just the URL not the actual image) to a database. Now I can manipulate however I want. When I feel like updating (I'm doing it manually now but could be a cron job or use the real-time api) I re-read all the images, compare to what I have in my DB and add possible new images. My app then reads out the url and info from my DB (which btw is a heck of a lot faster than going through the instagram api, which will only return about 25 images per request - regardless of any 'count' parameter value you put in the request url) and displays it.
I am developing this for a client who is afraid of people posting nsfw or whatever pics using their dedicated hashtag (for a contest) - with the above set up I can offer them an interface where they can check and mark images that are then displayed in the app.
One thing to watch out for is when a user deletes his picture; you will have to find a way to check for this. Currently (since I'm lazy) I load all images and use jquery to check for an error loading the image. If there is one I delete the image from the DB (via ajax).
I'm not sure the pagination is going to help you: as far as I can see the pagination response has no relation to the id's of the actual image objects on each page - so theoretically a pagination id that jumps to a certain page (i.e. date) might not work tomorrow if enough images have been deleted in the mean time.
to get all images instead of latest 20, just append &count=-1 to your api call - it's that simple.
In either case, there is a timestamp on each json object - or if you prefer, you can use max_tag_id
check out my post here: there any way to show more than 20 photos of the instagram API?
* Update April 2014: count=-1 is no longer available.

Resources