Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination support #10

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Pagination support #10

wants to merge 20 commits into from

Conversation

pavelsr
Copy link
Collaborator

@pavelsr pavelsr commented Oct 16, 2023

Issue #9

Before:

import logging
logging.basicConfig(level='INFO')
from yaschedule.core import YaSchedule
yaschedule = YaSchedule('TOKEN')
s_code = 's9600366' # Pulkovo
x = yaschedule.get_station_schedule(station = s_code)
print(x['pagination']) # {'total': 1533, 'limit': 100, 'offset': 0}
print(len(x['schedule'])) # 100

After:

import logging
logging.basicConfig(level='INFO')
from yaschedule.core import YaSchedule
yaschedule = YaSchedule('TOKEN')
s_code = 's9600366' # Pulkovo
x = yaschedule.get_station_schedule(station = s_code)
print(x['pagination']) # None
print(len(x['schedule'])) # 1533

Log after:

$ python3 09_pag.py 
INFO:yaschedule.core:GET https://api.rasp.yandex.net/v3.0/schedule/?apikey=REDACTED&lang=ru_RU&station=s9600366 200 55.97KB
INFO:yaschedule.core:Response(from_cache=True, created_at=2023-10-03 22:41:07.948567, expires=None, is_expired=False)
INFO:yaschedule.core:This is a paginated route, total: 1010, more requests for full result: 10
INFO:yaschedule.core:GET https://api.rasp.yandex.net/v3.0/schedule/?apikey=REDACTED&lang=ru_RU&offset=100&station=s9600366 200 56.27KB
INFO:yaschedule.core:Response(from_cache=True, created_at=2023-10-03 23:24:46.038717, expires=None, is_expired=False)
INFO:yaschedule.core:GET https://api.rasp.yandex.net/v3.0/schedule/?apikey=REDACTED&lang=ru_RU&offset=200&station=s9600366 200 56.84KB
INFO:yaschedule.core:Response(from_cache=True, created_at=2023-10-03 23:24:47.053363, expires=None, is_expired=False)
INFO:yaschedule.core:GET https://api.rasp.yandex.net/v3.0/schedule/?apikey=REDACTED&lang=ru_RU&offset=300&station=s9600366 200 56.63KB
INFO:yaschedule.core:Response(from_cache=True, created_at=2023-10-03 23:24:49.268924, expires=None, is_expired=False)
INFO:yaschedule.core:GET https://api.rasp.yandex.net/v3.0/schedule/?apikey=REDACTED&lang=ru_RU&offset=400&station=s9600366 200 56.96KB
INFO:yaschedule.core:Response(from_cache=True, created_at=2023-10-03 23:24:50.281402, expires=None, is_expired=False)
INFO:yaschedule.core:GET https://api.rasp.yandex.net/v3.0/schedule/?apikey=REDACTED&lang=ru_RU&offset=500&station=s9600366 200 56.55KB
INFO:yaschedule.core:Response(from_cache=True, created_at=2023-10-03 23:24:51.860339, expires=None, is_expired=False)
INFO:yaschedule.core:GET https://api.rasp.yandex.net/v3.0/schedule/?apikey=REDACTED&lang=ru_RU&offset=600&station=s9600366 200 56.81KB
INFO:yaschedule.core:Response(from_cache=True, created_at=2023-10-03 23:24:53.521164, expires=None, is_expired=False)
INFO:yaschedule.core:GET https://api.rasp.yandex.net/v3.0/schedule/?apikey=REDACTED&lang=ru_RU&offset=700&station=s9600366 200 56.05KB
INFO:yaschedule.core:Response(from_cache=True, created_at=2023-10-03 23:24:54.567958, expires=None, is_expired=False)
INFO:yaschedule.core:GET https://api.rasp.yandex.net/v3.0/schedule/?apikey=REDACTED&lang=ru_RU&offset=800&station=s9600366 200 56.37KB
INFO:yaschedule.core:Response(from_cache=True, created_at=2023-10-03 23:24:56.390511, expires=None, is_expired=False)
INFO:yaschedule.core:GET https://api.rasp.yandex.net/v3.0/schedule/?apikey=REDACTED&lang=ru_RU&offset=900&station=s9600366 200 56.68KB
INFO:yaschedule.core:Response(from_cache=True, created_at=2023-10-03 23:24:57.418172, expires=None, is_expired=False)
INFO:yaschedule.core:GET https://api.rasp.yandex.net/v3.0/schedule/?apikey=REDACTED&lang=ru_RU&offset=1000&station=s9600366 200 5.99KB
INFO:yaschedule.core:Response(from_cache=True, created_at=2023-10-03 23:24:59.137921, expires=None, is_expired=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants