How to get count of followers through Github API? - rest

I want to get count of my followers when each time the page loads.
The endpoint I found is api.github.com/users/tim-hub/followers, which can get all followers data (with pagination).
What the problems are (through restful api)
I do not need the followers details
Pagination is like 30 items each page, which makes it hard to count all of them
I am thinking about to fetch a page , i.e. page 4 ?page=4, and do a simple calculation 30*(4-1)+[count of page 4], but it means it will call multiple times, because the followers are changing, if it increases or decreases, I have to call to page 5 or page 3. and loop it until find the last page.
Why not GraphQL
GraphQL api seems like can be used to get the count, what the problem is that I want to call this through front-end, and Graph way requires authentication, I do not want to share my persona token to all.

Similarely to "How to find my organization Id over github?", you can use the GitHub user API to isolate the followers number.
curl -H "Accept: application/json" https://api.github.com/users/aUser | jq ".followers"
In my case:
curl -H "Accept: application/json" https://api.github.com/users/VonC| jq ".followers"
179
For a GraphQL-based solution, see "Github API - Find number of followers for all my followers".

Related

Mongodb API for getting application IDs does not return any value

I'm trying to write a Realm (AppService) Function to remove user's account.
I'm using curl command to check the API calls:
curl --request <METHOD> --header "Authrorization: Bearer <TOKEN>" <URL>
as advised here:
https://www.mongodb.com/docs/atlas/app-services/admin/api/v3/
First I want to call Mongodb DELETE api url: https://realm.mongodb.com/api/admin/v3.0/groups/${projectId}/apps/${appId}, but it returns 404 error, so to narrow down the problem I'm trying to call GET on https://realm.mongodb.com/api/admin/v3.0/groups/${projectId}/apps to get list of my APP IDs.
This URL, however, does not return any value - the response is empty.
If I change URL (e.g. app to applications), then I receive "404 page not found" response. So my URL appears to be valid, but for some reason it does not return any value.
Probably it is also the reason I cannot delete the user. Please help.

List all branches of a particular repository

I am trying to fetch all branches of one of my repository on git. It returns only 30 branches but it has more than that.
curl -H "Authorization: Bearer Token" https://api.github.com/repos/account_name/repo_name/branches
This curl lists only 30 branches. Is there any way to list all branches?
You can request more results per page using the per_page parameter:
https://developer.github.com/v3/#pagination
There is a limit to how many you can request per page, so you should always be prepared to follow their pagination guide.

Get multiple songs by foreing_ids

I'm building an spotify-echonest app using the web apis from both. I'm using spotify api to get as many songs as I can from user input, what I need now is to get information about these songs from echonest but as far as I can see you can only set one filter as foreing_id in the rest service.
http://developer.echonest.com/api/v4/artist/similar?api_key=YOUR_API_KEY&id=spotify:artist:4Z8W4fKeB5YxbusRsdQVPb&bucket=id:spotify
I'm using the Java API from Echonest, anyway any help is usefull.
You should query audio features from Spotify's Web API instead as Spotify doesn't support echonest anymore. I think you've already known how to get track IDs from the API, all you need to do is use the track IDs to query audio features.
Example:
Step 1: Get track id
curl -X GET "https://api.spotify.com/v1/search?q=track%3Anumb+artist%3Alinkin+park&type=track" -H "Accept: application/json"
Step 2: Get access token
curl H "Authorization: Basic YOUR_CLIENT_CREDENTIALS" -d grant_type=client_credentials https://accounts.spotify.com/api/token
Step 3: Get audio features
curl -X GET "https://api.spotify.com/v1/audio-features/YOUR_TRACK_ID" -H "Authorization: Bearer {YOUR_ACcess-TOKEN}"

Facebook Graph API Batch - Iterative paging

I'm trying to get all posts from a number of public Facebook pages. The following combined with some paging does this but it's slow as separate calls are required to traverse through each page of posts (and then comments and then replies if these are included).
curl -X GET "https://graph.facebook.com/FacebookDevelopers/feed?fields=id&access_token="$TOKEN
From what I can find in the facebook API documentation it seems like the batch endpoint is better for this but I'm having trouble getting all pages of posts.
The following takes the initial request and traverses forward one page (ie returning a total of 2 pages) but I can't get more than 2 pages.
curl \
-F 'access_token='$TOKEN \
-F 'batch=[{ "method":"GET","name":"getfeed","omit_response_on_success":false,"relative_url":"FacebookDevelopers/feed?fields=id"},
{ "method":"GET","omit_response_on_success":false,"relative_url":"FacebookDevelopers/feed?fields=id&after={result=getfeed:$.paging.cursors.after}"}]' \
https://graph.facebook.com
Is there a way to get all posts from a public page using the batch endpoint?
For each paging request you will the cursor parameter (for the after call). You can "nest" the batch calls only one level deep, you so can indeed only request two pages at the same time.
Besides the technical limitation, please also be aware that scraping is not allowed and there are request throttling limits.

Searching for playlists on soundcloud api returns 500 error

I'm trying to use the soundcloud api to find playlists with a specific tag. My first step in doing so is pinging the soundcloud api for all playlists. I run the following in my command line to do so (client id replaced for privacy):
curl 'https://api.soundcloud.com/playlists.json?client_id=MY_CLIENT_ID'
This always returns a 500 interval server error, whether I ask for it in json or normal xml:
curl 'https://api.soundcloud.com/playlists?client_id=MY_CLIENT_ID'
However, when I make the analogous request for tracks, it works fine:
curl 'https://api.soundcloud.com/tracks?client_id=MY_CLIENT_ID'
curl 'https://api.soundcloud.com/tracks.json?client_id=MY_CLIENT_ID'
What gives? Is this an error on my side or their side?
I don't think you can grab all playlists. There must be millions of them, and that is a lot to return.
If you look here at the Soundcloud API Docs, they add a playlist id to the URL.
$ curl "http://api.soundcloud.com/playlists/405726.json?client_id=YOUR_CLIENT_ID"
Hopefully this helps!