C
C
Chinato2021-07-02 03:31:42
API
Chinato, 2021-07-02 03:31:42

How do you get an API?

Hello, the question may not seem clear, but I am new to this business and do not fully understand what the API in general means and how to get it.

My friend told in short how to get some requests with which you can interact with the server (or with the application), but they need to be found in data packets and if they are encrypted, then you need to disassemble the application and find the decryption key generator ... And then I did not understand anything at all.

Please tell us in simple words (analogies are welcome) what is going on with this API and what is it all about?
What are the requests and how can they be obtained if the program code has changed and the old requests (API, I just don’t know how to put the question correctly) have become unavailable?

If necessary, then the application in Java.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HemulGM, 2021-07-02
@Citayto

Wiki

API (application programming interface, application programming interface) (English application programming interface, API [hey-pee] [1]) - a description of the ways (a set of classes, procedures, functions, structures or constants) in which one computer program can interact with another program

In a simple
API, it is a set of rules by which you can establish communication between different systems. This is what provides some service. He develops it and he gives it to use.
An example with the same weather. There is a service - Weather. He decided that he could provide weather data to everyone.
You will say - "well, they have a website and everything is written there", but in order to use weather data in your own program, you will have to "parse" the whole page. It is inconvenient, costly and unstable.
To do this, developers develop a set of rules, in this case - requests. The execution of which will return strictly defined information.
The same API can allow you to add / modify and delete information (REST).
API is usually documentation. An example of such documentation (API) for weather is https://openweathermap.org/current
If you delve deeper into the question, you will come across concepts such as a token or key that determine the level of access to API methods. Some APIs can work without these things, but for the most part, everyone uses tokens. At least nominally.
API - allows you to do only what the developers have implemented. And if they haven't added methods, like setting the current temperature, you can't change it.
Another point regarding the topic is not to confuse the API and emulation of requests from the service site. Those. look at what the site calls at work ("search in packages") and call the same thing - this is not an API.
Additionally

API is not only about requests. API is a broader concept than access to the server.
Through API work, for example, all programs in Windows - WinAPI. Through the API, programs interact with each other. Plugins in the browser use the browser API to work with plugins.

A
Anastasia, 2021-07-02
@nastya97core

d9a5c7a5629a4580bdf07dbe4882ca2a
I will give the simplest example with getting data. In fact, the API's possibilities are unlimited. Anything you want is possible. It's just that most often the API is used to get some kind of data.
The principle is this:
There is a site with the weather. To get the temperature in St. Petersburg, which they measured, you need to go to their website, type SPB in the search parameters and look with your eyes.
And so, to meet the need to "know the weather" - you just need to go to their site. But if you want your site/app/game to have the weather, then there will be problems
- In fact, you could just go to the weather site every 10 minutes, take data from there and upload it to your site. Agree - uncomfortable.
- Or you could set up a bot that would enter the site, simulating a user and get the temperature from the desired block, and then insert the results into your site. In fact, they do this when there is no API, but this is not a completely stable channel: a) you can be banned by ip for strange requests; b) if the layout of the site (the order of the blocks) changes, then of course you will no longer be able to get the temperature and you will have to rewrite the bot
And here API comes to the rescue. The principle is this: you can agree with the temperature supplier that you will take data from them. It can be either a paid service or a free one (usually it depends on the number of requests). As a result, you are given a link that already contains all the parameters that you need, and you simply set up your bot to get this data from the link and insert it on your site.
To see the temperature in St. Petersburg you need to open the link:

http://api.openweathermap.org/data/2.5/weather?q=Санкт-Петербург&units=metric
won't work, because the API key is not specified here.
Why do you need an API key?
As I said: APIs are paid and free, and their payment usually depends on the number of requests that you make. But how does the supplier know who is making the request: me, you, or that guy? To regulate this - they assign you your personal number (ID), by which they will track how many requests you have already made. Your rights are also laid down in your ID. Maybe look at the weather in St. Petersburg - for free, but if you want to know the exact temperature in the conditional Kudrovo, then be kind - pay extra and then they will provide access to this temperature using your ID. Briefly: API-key - password from your account.
And here is the correct link for you:
http://api.openweathermap.org/data/2.5/weather?q=Санкт-Петербург&units=metric&appid=0f47096f1eb155f8b277692876fb963e

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question