Pagination for search - dockerhub API - pagination

I need to get all repositories with a provided name from DockerHub. I already tried various ways to get to next page of results received for the following call:
curl -k -H "Accept: application/json" -X GET https://index.docker.io/v1/search?q=sonarqube
Options which haven't worked:
curl -k -H "Accept: application/json" -X GET https://index.docker.io/v1/search?q=sonarqube&n=25&page=2
curl -k -H "Accept: application/json" -X GET https://index.docker.io/v1/search?q=sonarqube&page_size=25&page=2
Am I missing anything, or is there an alternative to get these results?

I simply used this link to navigate to the second page:
https://index.docker.io/v1/search?q=sonarqube&page=2
I works for page attibute range from 1 to num_pages which is returned in the JSON response. If you provided a number higher than num_pages it returns the last page.
Curl command as requested:
curl -k -H "Accept: application/json" -X GET "https://index.docker.io/v1/search?q=sonarqube&page=2"

Related

How do I interact with the hackage API using curl?

There are sparsely documented methods here. This page just mentions there's an API, and links to the hackage-security library which 5min poking around doesn't help me figure out how to form an http request to the (which?) server
The following just get me a stub html file:
$ curl -H "Accept: application/json" hackage.org/package/aeson/
$ curl -H "Accept: application/json" hackage.org/api/package/aeson/
old related: Does Hackage have an API?
You have the base URL wrong. It's https://hackage.haskell.org/.
curl -H 'Accept: application/json' https://hackage.haskell.org/package/aeson
yields the output
{"0.1.0.0":"normal","0.10.0.0":"deprecated","0.11.0.0":"normal","0.11.1.0":"normal","0.11.1.1":"normal","0.11.1.2":"normal","0.11.1.3":"normal","0.11.1.4":"normal","0.11.2.0":"normal","0.11.2.1":"normal","0.11.3.0":"normal","0.2.0.0":"normal","0.3.0.0":"normal","0.3.1.0":"normal","0.3.1.1":"normal","0.3.2.0":"normal","0.3.2.1":"normal","0.3.2.10":"normal","0.3.2.11":"normal","0.3.2.12":"normal","0.3.2.13":"normal","0.3.2.14":"normal","0.3.2.2":"normal","0.3.2.3":"normal","0.3.2.4":"normal","0.3.2.5":"normal","0.3.2.6":"normal","0.3.2.7":"normal","0.3.2.8":"normal","0.3.2.9":"normal","0.4.0.0":"normal","0.4.0.1":"normal","0.5.0.0":"normal","0.6.0.0":"normal","0.6.0.1":"normal","0.6.0.2":"normal","0.6.1.0":"normal","0.6.2.0":"normal","0.6.2.1":"normal","0.7.0.0":"deprecated","0.7.0.1":"deprecated","0.7.0.2":"deprecated","0.7.0.3":"deprecated","0.7.0.4":"normal","0.7.0.5":"deprecated","0.7.0.6":"normal","0.8.0.0":"deprecated","0.8.0.1":"deprecated","0.8.0.2":"normal","0.8.1.0":"normal","0.8.1.1":"normal","0.9.0.0":"normal","0.9.0.1":"normal","1.0.0.0":"normal","1.0.1.0":"normal","1.0.2.0":"normal","1.0.2.1":"normal","1.1.0.0":"normal","1.1.1.0":"normal","1.1.2.0":"normal","1.2.0.0":"normal","1.2.1.0":"normal","1.2.2.0":"normal","1.2.3.0":"normal","1.2.4.0":"normal","1.3.0.0":"normal","1.3.1.0":"normal","1.3.1.1":"normal","1.4.0.0":"normal","1.4.1.0":"normal","1.4.2.0":"normal","1.4.3.0":"normal","1.4.4.0":"normal","1.4.5.0":"normal","1.4.6.0":"normal","1.4.7.0":"normal","1.4.7.1":"normal","1.5.0.0":"normal","1.5.1.0":"normal","1.5.2.0":"normal","1.5.3.0":"normal","1.5.4.0":"normal","1.5.4.1":"normal","1.5.5.0":"normal","1.5.5.1":"normal","1.5.6.0":"normal","2.0.0.0":"normal","2.0.1.0":"normal","2.0.2.0":"normal","2.0.3.0":"normal"}

curl command with queryparameter for passing urlencode

I have been hitting a curl command with queryparametr in the request and passing a json format in the query parameter , but I am getting error like (" some well formatted json in parameter query.unexpected character encountered parsing error while parsing value .
curl -g --request GET -H "Content-Type:application/json" -H "apitoken:abcd" "https://odat.abc.com/api/data?query=$(echo '$jsonInput')"
jsonInput is the json format file we are passing here.
See https://stackoverflow.com/a/32980082/1395722
curl -G --request GET -H "Content-Type:application/json" -H "apitoken:abcd" "https://odat.abc.com/api/data" --data-urlencode "query=$(echo $jsonInput)"

how to write curl command for getting data which updated in last 10 min

i have tried these two curl command but not getting correct response
curl --request GET 'https://localhost:8080/api/alarms?sort-by=lastReceiveTime&from-date=date -d'now-10 minutes'' -H 'Authorization: Key demo-key
curl --request GET 'https://localhost:8080/api/alarms?sort-by=lastReceiveTime&from-date="'"$(date --utc +%FT%T.%3NZ) -d 'now-10 minutes'"'"' -H 'Authorization: Key demo-key'
this command gives all alarm ...but we want only those alarm which came in last 10 min.

Using gitlab api, how do I get a list of active users?

Gitlab-CE v8.14.3
I'm reading the GitLAB API docs, and am trying to get the list of active users. I'm an admin and created a personal token. I do this
$ curl -XGET "Private-Token: kfjakjfkjkd" https://company.domain.com/api/v3/users?active=true
and keep getting 401 (Unauthorized) error. Like I said, I'm an admin. What gives?
You must specify the header using the -H option as noted in Bertrand Martel's answer. That will retrieve up to 20 users.
Above 20 users, you must get fancier. The JSON output is paginated, and each query is limited to 100 users per page. So to get 300 users, you must get three pages, 100 users at a time:
curl -H "Private-Token: kfjakjfkjkd" "https://company.domain.com/api/v4/users?active=true&per_page=100&page=1" > gitlabusers1.json
curl -H "Private-Token: kfjakjfkjkd" "https://company.domain.com/api/v4/users?active=true&per_page=100&page=2" > gitlabusers2.json
curl -H "Private-Token: kfjakjfkjkd" "https://company.domain.com/api/v4/users?active=true&per_page=100&page=3" > gitlabusers3.json
You need to specify that Private-Token: kfjakjfkjkd is an HTTP header with -H :
curl -H "Private-Token: kfjakjfkjkd" https://company.domain.com/api/v4/users?active=true

curl command in linux

How we can add JSON parameters in a curl command to fetch data ?
PS: I have tried to fetch data from some source using curl command but it requires passing JSON parameters in it. So how I will accomplish it ?
I think mentioning content type as json and passing data will do the things right
curl -H "Content-Type: application/json" -d '{"key1":"value1","key2":"value2"}' http://domain.com/rest/path/here
Above will work for GET Method, for POST method
curl -H "Content-Type: application/json" -X POST -d '{"key1":"value1","key2":"value2"}' http://domain.com/rest/path/here

Resources