Skip to content

AskfmForHumans/askfm-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

askfm-api

PyPI version PyPI status Code style: black pdm-managed

WARNING!
This library is outdated and doesn't support much of ASKfm's new functionality.
It is based on reverse-engineering ASKfm Android app v4.67.1 (API version 1.18) from the year 2020.

This aims to be a powerful Python wrapper around the undocumented ASKfm API for its mobile apps.

The core logic is quite complete, but only a small subset of API methods have helpers in the askfm_api.requests module so far.

Feature highlights

  • iterators for paginated requests
  • full error hierarchy based on semantics
  • automatic session refreshing

Usage

The code should be self-explanatory so I won't go into great detail here. A quick example:

from askfm_api import AskfmApi, AskfmApiError
from askfm_api import requests as r

try:
    api = AskfmApi("<signing key>")
    me = api.log_in("<username>", "<password>")
    print(me)
    # {'uid': 'jgrdlgrd', 'fullName': 'Снег не растает', 'location': 'my empire of dirt', ...}

    qs = api.request_iter(r.fetch_questions())
    print(next(qs))
    # {'type': 'daily', 'body': 'Hi?', 'answer': None, 'author': None, 'qid': 153352, ...}

    res = api.request(
        r.post_answer(question_type="daily", question_id=153352, text="Hi there!")
    )
    print(res)
    # {'question': {...}, 'answer': {...}}
except AskfmApiError as e:
    print(e)
    # error code returned by the API, e. g. 'session_expired'

Signing key

All requests are signed using a secret key (unique per app version) that is stored inside the official app in an obfuscated manner. I don't find it ethical to publish it, so if you want to use this library, your options are:

  • extract the key by yourself
    • hint 1: use APK version 4.67.1
    • hint 2: if you found "YKhyxNvWDwMhHxPpmHMZecqsXCKzS" — that's not the key, but you are on the right path :)
  • contact me, explain your use case and ask for the key

Todo

  • feat: Add more method helpers
  • tests: Add tests

Related work / See also

Contributing

Any activity is welcome, but I would be especially grateful if someone wrote tests for this code.