Skip to main content

Unofficial API wrapper for https://ask.fm

Project description

askfm-api

PyPI version PyPI status Code style: black Project manager: pdm

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

Currently based on reverse-engineering ASKfm Android app v4.67.1, which uses ASKfm API version 1.18. 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. Quick example:

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

try:
    api = AskfmApi("<secret key>", device_id="D2A6C471C4B4DA5C")
    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
  • 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.

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

askfm-api-0.2.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

askfm_api-0.2.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file askfm-api-0.2.0.tar.gz.

File metadata

  • Download URL: askfm-api-0.2.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for askfm-api-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0cc9f9c6f3f2af28ffe57f0371c33d1b29bd203fe8fecef7d8c4446a2ad8be57
MD5 ba1e93534793b38372c5be23eb0f35b4
BLAKE2b-256 bb9e18015af857f186fc363e27ac7433bad17188b8ad9c8a3dc0416e045ec472

See more details on using hashes here.

File details

Details for the file askfm_api-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: askfm_api-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for askfm_api-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4ddff0fe2331df45bf80afe856bc05e300ec2d3b5c3e0789331cad26d80e6df
MD5 374069e2179ea955ab0a3bb84f0e84fc
BLAKE2b-256 fe60ceae0a3c568c99afd018c4ac3e1ce32d0360004ccd4f867ba5afc68d8a5b

See more details on using hashes here.

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