Study Note For API’s: These Two

作者: 此之木 | 来源:发表于2019-10-04 21:13 被阅读0次

What is API’s?

API’s stands for application programming interface.

They are interfaces for code or computers to talk to one another. For example, we can use a Facebook account to login to Instagram. When we connect these two apps, Instagrams will link to and access your Facebook data. When you upload photos on Instagram, it will be automatically uploaded on Facebook, too.

We also use a lot of Web API’s every day. Web API’s generally to communicate via HTTP. For example, we may ask Yelp API’s to recommend 10 nearby Sushi restaurants in a certain zip code.

Data Formats

There are two main formats that web API is responded with: XML and JSON.

When we use the internet, we make an HTTP request and get HTML back. API’s don’t respond with HTML because HTML contains information about the structure of a page.API’s respond with data, not structure.

1. XML

XML stands for Extended Markup Language.

It is syntactically similar to HTML, but it doesn’t describe presentation like HTML does.

For example, we make personal data in XML like this:

All XML does is code key-value pairs. It looks like HTML in syntax format, but it is not. It is just displaying the basic information of a person such as a name, age, and gender in closing tags.

2. JSON

JSON stands for JavaScript Object Notation.

JSON is another way of storing data and sending that data back. It looks exactly like JavaScript objects, but everything is in a string.

We use the same example, but we write it in JSON format:

Comparing to XML, JSON is a much easier option. It is short and contains less text where we don’t have to write those closing tags. It also works great with JavaScript which we are going to write it in most time.

相关文章

网友评论

    本文标题:Study Note For API’s: These Two

    本文链接:https://www.haomeiwen.com/subject/vbtotctx.html