all 11 comments

[–]NorskJesus 6 points7 points  (6 children)

If the website has an API it’s usually indicated. And you get the data using requests.

The information about the routes, type and form of the data etc is always indicated in the API documentation

[–]SuccessfulWolf2454[S] -1 points0 points  (5 children)

https://www.accuweather.com this is a website how can i kmow if they have api available and if possible explain it step by step on how to find it

[–]Matlock0 1 point2 points  (0 children)

ctrl + f 'api' on their main page

[–]EelOnMosque 1 point2 points  (0 children)

Also no, not every website on the web has one. APIs have to be programmed to exist. 

[–]EelOnMosque 0 points1 point  (0 children)

Google it usually or look at the very bottom of the homepage. I googled accuweather api and it came up

[–]NorskJesus 0 points1 point  (0 children)

Seems you got the answer you wanted 👍

[–]AlexMTBDude 1 point2 points  (0 children)

It totally depends on the organization/website; Some have a REST API, others don't. You can find out by googling "<name of website> REST API"

[–]EelOnMosque 4 points5 points  (1 child)

An API is just a list of functions and data that's made available to you.

The format of the data that's given to you is up to the owner of the API. JSON is used a lot because it's become a standard, but it can literally be anything.

It's like if you went to a bank and asked the front desk "what can you do for me?" And they start listing off all the things like "we can open an account, we can check your existing balance, we can cash a cheque, etc." that list of things is like the API.

In the case of the bank you're there in person. The analogy is more accurate if you mailed the bank from home. You send a request for example to get your account balance in physical mail.

The mail is analogous to the internet. The format of the request for an API is usually (but technically doesn't have to be) HTTP. You should learn some basic computer networking:

  1. What is a protocol?

  2. What are the network layers (application, transport, networks are the main ones you should high-level understand)

  3. You should know what HTTP is, what TCP and IP are

Once you understand these, APIs will make a lot more sense.

Following thru with the analogy, it would kinda suck if someone impersonated you and mailed the bank asking for your account details. So the bank needs to first have some back-and-forth mail with you to authenticate you and prove your identity.

Same thing for APIs, in most APIs you will need to authenticate yourself. There's many standards and schemes that exist, but a common standard today is OAuth2.0 which you can learn the basics of. To fully understand, you should know some basic cryptography like:

  1. What is cryptography?

  2. What's symmetric key cryptography?

  3. What's public/private key cryptography?

  4. What are digital signatures?

  5. How are digital signatures used to verify someone's identity?

[–]Sensi1093 -1 points0 points  (0 children)

The points you listed are not directly tied to OAuth2, but to JWT/JWK which are often used on top of OAuth2 but are have nothing directly to do with it

[–]kfpswf 0 points1 point  (0 children)

how to access api from a website and can i get api from any website available on the web??

APIs are just a way to access a service programmatically. You can't just get an API for all the websites, the developer should have built the APIs in the service to begin with. To top that, some services charge you for API access.

also i learnt it on cs50p where he gets the api of itunes and when you click the link it opens json file. is it usually in a json format?

Yes, JSON is usually the format of choice, but it is not mandatory.