Skip to main content Python REST API wrapper

Project description Python REST API wrapper


This is (Russian social network) python API wrapper. The goal is to support all API methods:

Getting Started

Install package using pip

pip install aiookru

To use OK API you need a registered app and account in the social network.

  1. Sign up in
  2. Create external application.
  3. Save App ID, App key, App secret key.
  4. Use App ID, list of required permissions and user credentials to get access token.
  5. Use the access token to make method requests.

After signing up go to and create application.

app_id = 'app ID'
app_key = 'app key'
app_secret_key = 'app secret'


You can authenticate with OK API OAuth by passing user credentials and permissions to ImplicitSession (or ImplicitClientSession/ ImplicitServerSession).

from aiookru.sessions import ImplicitSession

phone = '+1999123456'
password = 'user password'

session = await ImplicitSession(

Now you can execute API requests (see Executing API requests). After authentication you will get access token session.access_token and session secret key session.session_secret_key. Save them to make requests later:

access_token = session.access_token
session_secret_key = session.session_secret_key


If you already have either of two:

  • app_secret_key and access_token
  • session_secret_key
from aiookru.sessions import TokenSession

session = TokenSession(

you can instantiate TokenSession (or ClinentSession/ServerSession) and execute requests.

Executing API requests

from aiookru import API

api = API(session)

# current user's friends
friends = await api.friends.get()

Under the hood each API requests is encriched with:

  • application_key
  • sig
  • app_secret_key and access_token or session_secret_key
  • format
  • method

By default, the sessions try to infer which signature circuit to use:

  • if app_secret_key and access_token are not empty strings - server-server signature circuit is used
  • else if session_secret_key is not empty string - client-server signature circuit is used
  • else exception is raised

You can explicitly choose a circuit for signing requests by passing to API one of the following sessions:

Sever-Server circuit

from aiookru import ImplicitServerSession, API
session = await ImplicitServerSession(app_id, app_key, app_secret_key, phone, password)
api = API(session)

or if you already have an access token

from aiookru import ServerSession, API
session = ServerSession(app_key, app_secret_key, access_token)

Client-Server circuit

from aiookru import ImplicitClientSession, API
session = await ImplicitClientSession(app_id, app_key, phone, password)
api = API(session)

or if you already have a session secret key

from aiookru import ClientSession, API
session = await ClientSession(app_key, session_secret_key)
api = API(session)


aiookru is released under the BSD 2-Clause License.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiookru-0.0.1.tar.gz (7.3 kB view hashes)

Uploaded Source

Built Distribution

aiookru-0.0.1-py3-none-any.whl (8.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page