M
M
Marat Akhmetshin2016-01-08 08:08:04
Python
Marat Akhmetshin, 2016-01-08 08:08:04

How to use GET type methods in Python language?

Hello!
I have a task. There is an electronic journal API that contains methods and parameters that need to be accessed in order to access information. I am writing a script for a Telegram bot that will send a request to the EJ and transfer it to the end user on the other side of the Telegram. I realized that I need to use the request library for python. I spied a course on Codecademy.
But I still don't understand a couple of things:
1. How are methods like getRules used in Python?
Should it be requests.get("rules",...) or requests.getrules("...")?
2. How to transfer data like user, password, vendor in the same python?
3. Where can I read good literature on this topic?
That's all for now :) Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VZVZ, 2016-01-08
@bukrat

You seem to be confusing some "methods" with other "methods".
First, there are no "methods like GET".
This is called "GET requests", which means "GET requests". In HTTP terminology, the word "method" means "request type".
And the API methods (which, apparently, is getRules) is the address (URL) to which you need to make an HTTP request using the GET method or the POST method.
The address must be complete. The documentation may omit full addresses for requests, instead of them there are so-called "API methods".
But in any case, you need to get the full URL. It should be in the documentation somewhere (its first part is common to all "API methods"). It can also be found by googling.
Here is the documentation with a list of "API methods":
vk.com/dev/methods
Here is the description of the "method" in it called "users.get":
vk.com/dev/users.get
And here is the full URL we get in the end :
Here is this part - " api.vk.com/method " - it is common for all "API methods" in the case of the VK API.
Of course, for some other API, it will be completely different. You need to find it - in the documentation or in Google. This is possible if you google code examples with this API.
We can open this full URL in a browser (because the API supports GET requests) and see that everything works. We can also send a GET request on it programmatically, it will turn out like this:
I also recommend downloading and installing the Fiddler sniffer, this is an almost indispensable tool for those who write bots.
It allows you to intercept all GET / POST requests from your computer, it can be used for debugging and reverse engineering.

S
Sergii Buinytskyi, 2016-01-08
@boonya

Well actually the best literature on python requsts is the documentation .
What do you mean by "methods like getRules in Python"?
Regarding the passing of arguments, there is a good example on the first page of the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question