List all branches of a particular repository - github

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.

Related

Why does Github actions rest API download artifacts by creating a temporary URL?

I am following the docs here https://docs.github.com/en/rest/actions/artifacts#download-an-artifact to use Github actions rest API to download artifacts. Given an ARTIFACT_ID and access token if the repo is private, one can call the API via cURL or the github CLI to get a response from github. The response header contains Location:... which provides a temporary URL lasting 1 minute from which the artifact can be downloaded. The artifact can then be downloaded via a second call to cURL.
I would like to know the reason for this design decision on the part of Github. In particular, why not just return the artifact in response to the first call to cURL? Additionally, given that the first call to cURL is intended to return a temporary URL from which the artifact can be retrieved, why not have this temporary URL returned directly by call to cURL rather than having it only contained in the header. Other information such as if the credentials are bad, or if the object has been moved are returned in json when this cURL command is run, so why can't the temporary URL also be contained here?
To help clarify my question, here is some relevant code:
# The initial cURL command looks something like this:
curl -v \
-H "Accept: application/vnd.github+json" \
-H "Authorization: token <TOKEN>" \
https://api.github.com/repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID/ARCHIVE_FORMAT
# the temporary URL, which can be curled to retrieve the artifact, looks like something like this:
curl https://pipelines/actions/githubusercontent.com/serviceHosts/<HEXSTRING>/_apis/pipelines/1/runs/16/\
signedartifactscontent?artifactName=<artName>&urlExpires=<date>&urlSigningMethod=HMACV2&urlSignature=<SIGNATURE>
Additionally, I am currently capturing the standard error of the cURL command and then running regex on it so as to extract the temporary URL. Is there a better way to do this? For example, is there a flag I could pass to cURL that would give me the value of Location directly?
Additionally, it is stated that The archive_format must be zip. Given this is the case, what is the benefit of having this parameter. Is it not redundant? If so, what is the benefit of this redundency?
This is a consequence of a 2011 design decision regarding https://github.blog/2011-08-02-nodeload2-downloads-reloaded/
When implementing a proxy of any kind, you have to deal with clients that can’t read content as fast as you can send it.
When an HTTP server response stream can’t send any more data to you, write() returns false.
Then, you can pause the proxied HTTP request stream, until the server response emits a drain event.
The drain event means it’s ready to send more data, and that you can now resume the proxied HTTP request stream.
TO avoid DDOS, it is better to manage that stream from a temporary URL, rather than a fixed one.
You can use -D to display response header, but you would still need to post-process its answer to get the redirection URL.

Is there a way of getting only the issues without a certain label using the GitHub Api

I have the following
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token <TOKEN>" \
https://api.github.com/repos/OWNER/REPO/issues?labels=label
Currently I am only able to get the issues that have a certain label using the GitHub api, is there a way to get all the issues that doesn’t have a specific label using the GitHub api?
Based on github DOC, It's not possible
labels string
A list of comma separated label names. Example: bug,ui,#high
One solution would be to implement it. You can get all the issue then iterate using a loop to remove the issue that has the specific label

How to get count of followers through Github API?

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".

Github Pinned Repositories REST call without using graphQl

I'm trying to sort out how to make a call to Github's API to get a hold of my pinned repos but I can't seem to find anything from Github's documentation using a REST call.
I did find this which uses graphql and does what I want but I'm not looking to spin up another server for this project.
so far I'm using https://api.github.com/users/USERNAME/repos. Has a good amount of what I want but nothing for pinned repos.
anyone know?
As #Wilhelm said, you do not need your own servers to make a GraphQL call.
Have a look here to get started.
Briefly,
https://api.github.com/graphql POST request
Authorization: bearer <token> header
{ "query": "query MyQueryToGithub { ... }" } JSON payload

Are there any ways to get/export list of comments for particular project/branch in Github?

Are there any ways to get/export list of comments for particular project/branch in Github?
Is there available any plugin/api?
Is Github giving any solvents for
this?
I found the below question which is related to this but seems the answer is only for getting the comments for a particular commit on Github.
Get list of comments from GitHub pull request
Thank you!
Relevant GitHub api documentation.
I think what you are looking for is something like this:
https://api.github.com/repos/{owner}/{repo}/comments
So if the repository you are interested in obtaining information for is angular, your request would be:
https://api.github.com/repos/angular/angular/comments
To obtain, all of the comments for that repository, you must know their Api limits to 100 results per request(and has some other limits, such as 60 unauthenticated requests per hour). So depending on how programmatically you are doing this, you would want to make your requests as follows:
https://api.github.com/repos/angular/angular/comments?page=1&per_page=100
https://api.github.com/repos/angular/angular/comments?page=2&per_page=100
etc...
UPDATE:
Following the additional information provided in the comments, for this to work with a private repository, you would need to do two things.
Update the url you are using to https://api.github.com/user/repos/{owner}/{repo}/comments
Documentation
Provide the appropriate authentication to the requests. One way to do this is through the headers. Add both of the following headers:
User-Agent: 'YOUR_USERNAME'
Authorization: 'token YOUR_TOKEN'