How to make post request to a given api - api

Assume the url is
www.example.com
I'm trying to make a post request using Postman to the following API.
sample1, /sample2, ...,/sample10
I can't figure out what's that mean. Should I put api as key, and /sample1 in the params? Or put them in the header? Thanks

Your setup would be:
/sample1 sample10 are just parts of the url you're posting to. To add the header click on the header tab and add a key/value for the headers you want to send.

Related

How to make api get requests from dukascopy?

I have an api key but i'm not sure on how to make an get request using their api.
The documentation is a bit vague on how to format the url, any help is appreciated!
Documentation:
https://www.dukascopy.com/trading-tools/api/documentation/quotes
To use the API you just need to append your key in the URL like,
https://freeserv.dukascopy.com/2.0/?path=api/lastOneMinuteCandles&key={you_api_key}
Another example,
https://freeserv.dukascopy.com/2.0/?path=api/currentPrices&key={api_key}&instruments=EUR/USD,USD/JPY
You can use Postman, and should see some values come back (since my key is not valid, I got 401).

scrapy not visiting url after #

I am writing a scraper for a site. however weird thing is happening, it's not visiting the URL i supply to him. Rather it visits the base url of the website.
I searched on the internet and came to know that, scrapy would ingnore URL after #, I need to indentify the Ajax request being sent and mimic that.
However the problem is. the response of the Ajax request comes as json response. it's not a html content. Would someome please help me how to deal with it.
Following is the url
https://www.buildersshow.com/Search/Exhibitors.aspx#showID=11&state=160&tabname=name
If you investigate the AJAX requests that the page makes, identify the request you need to make and get your response, it should be JSON contained in the response body. To parse it and get your data of interest, use the json decoder/encoder module. Something like this:
import json
mydata = json.loads(response.body)
info = mydata['somekey']
subinfo = mydata['somekey']['subkey']
And so forth. Make sure to handle the json decoder the proper way, it would be best to read the official documentation first.

what does POST stand for in an API header url?

I'm trying to access an API with the pattern POST /api/quotes/params?. . . and GET /api/quotes/3 but I don't know what the POST/GET are for. Am I supposed to replace them with something? I understand normal HTTP GET/POST requests but don't see the relevance in this caseā€¦ please help shed some light.
They are just normal HTTP methods. Generally, GET requests only fetch data, they don't modify anything on the server. POST requests are used to modify data by submiting a post body.
When should I use GET or POST method? What's the difference between them?
They just indicate how you should make your request and/or which methods are available for each endpoint.

Understanding the Reddit API - URL vs headers vs body

Here's the API.
This is my first time working with web APIs so bear with me. Where do the name-value pairs listed under each call belong in my HTTP request? Do they go in the URL, the headers, or the body? Is it different depending on if it's a GET request or a POST?
Are the answers to these questions true in general, i.e. for any web API?
Where do the name-value pairs listed under each call belong in my HTTP request?
In a GET, they're in the URL's query string. in a POST, they're in the request body. Headers never contain request parameters, but things like Content-length do control them, a bit. You might also run across JSON in a POST body (I can't remember if reddit does this). This is not reddit-specific, and is standard HTTP.

Github API - trying to access multiple pages of /users

I am playing around with Github's API and I noticed that they allow anyone to request all users that have signed up in chronological order.
https://api.github.com/users
http://developer.github.com/v3/users/
I was trying to get the second page but for some reason their pagination isn't working for me. I wasn't sure what I was doing wrong.
https://api.github.com/users?page=2
https://api.github.com/users?start_page=2
http://developer.github.com/v3/ Under "Pagination".
Anyone know the right way to do this?
Check out the returned HTTP headers for the https://api.github.com/users resource. Specifically, look for the Link header, which will look like this:
Link:<https://api.github.com/users?since=135>; rel="next", <https://api.github.com/users{?since}>; rel="first"
So, what you need to do is do an HTTP GET on https://api.github.com/users?since=135 to get the next page. After that, check the Link header again and you will get to the next page, etc. Also notice the provided URI template https://api.github.com/users{?since} which enables you to start at any id.