How to get access to the Yandex Forms API
Use the OAuth 2.0 protocol to access the Yandex Forms API.
In requests, specify these headers:
-
Host: api.forms.yandex.net -
Authorization: OAuth <OAuth_token>
Getting access to the API via OAuth 2.0
To access Yandex Forms API, you need to obtain an OAuth token. Use the obtained token in the Authorization header when making requests to Yandex Forms API.
This token grants the same permissions that the user account has in Yandex Forms. For example, if the user doesn't have permissions to receive form responses, the user can't make API requests to retrieve them with this token.
To get a token:
-
Click the link https://oauth.yandex.ru/.
-
On the Your apps page, click Create.
-
In the window that opens, select For API access or debugging and click Go to creation.
-
Enter the app name and your contact email.
-
Add permissions for accessing user data. To select a permission, start typing its name in the Permission name field:
- Изменение настроек форм (forms:write) — All operations with data: creation, deletion, and editing.
- Просмотр настроек форм (forms:read) — Reading only.
-
Click Create app.
-
In your Yandex OAuth account, select the previously created application and copy its ID from the ClientID field.
-
Next, generate a link to request a token:
https://oauth.yandex.ru/authorize?response_type=token&client_id=<application_ID> -
Log in to the account which you'll be using to access the API, then follow the generated link.
You'll see a sequence of characters appear on the page — that's your OAuth token. Copy and save it.
See how to set up your app in Yandex ID Help:
To check if you have access to the API, send any request. If no access permission is granted, you'll get a response with code 401 Unauthorized.
For example, to retrieve information about the current user with curl:
curl -X GET 'https://api.forms.yandex.net/v1/users/me/' \
-H 'Authorization: OAuth ABC-def12GH_******'
curl -X GET "https://api.forms.yandex.net/v1/users/me/" ^
-H "Authorization: OAuth ABC-def12GH_******"