駅すぱあと API SDK for Python
駅すぱあと APIをPythonから利用するためのSDKです。
インストール
pip でインストールします。
pip install ekispert
初期化
初期化時には、駅すぱあと APIのAPIキーを指定します。APIキーはトライアル申し込みより取得してください。
from ekispert.client import Ekispert
client = Ekispert("YOUR_API_KEY")
駅情報の取得
駅情報取得APIを実行します。検索条件、結果は駅情報 - 駅すぱあと API Documents 駅データ・経路検索のWebAPIを参照してください。
query = client.stationQuery()
query.code = 22828
points = query.execute()
assert len(points) == 1
assert points[0].station.name == '東京'
assert points[0].geo_point.lati_d == 35.678083
assert points[0].prefecture.name == '東京都'
assert points[0].prefecture.code == 13
駅簡易情報の取得
駅簡易情報APIを実行します。検索条件、結果は駅簡易情報 - 駅すぱあと API Documents 駅データ・経路検索のWebAPIを参照してください。
query = client.stationLightQuery()
query.name = '東京'
points = query.execute()
assert len(points) > 0
assert points[0].station.name == '東京'
assert points[0].prefecture.name == '東京都'
assert points[0].prefecture.code == 13
平均待ち時間探索
平均待ち時間探索APIを実行します。検索条件、結果は平均待ち時間探索 - 駅すぱあと API Documents 駅データ・経路検索のWebAPIを参照してください。
query = client.searchCoursePlainQuery()
query.from_ = 25077
query.to = 29090
courses = query.execute()
assert len(courses) > 0
assert courses[0].routes[0] is not None
assert courses[0].prices[0].kind == "ChargeSummary"
assert courses[0].prices[0].one_way == 2530
assert courses[0].prices[0].round == 5060
経路探索
経路探索APIを実行します。検索条件、結果は経路探索 - 駅すぱあと API(旧:駅すぱあとWebサービス) Documents 駅データ・経路検索のWebAPIを参照してください。
query = client.courseExtremeQuery()
query.via_list = ['22671', '22741']
query.answer_count = 1
courses = query.execute()
assert len(courses) == 1
assert courses[0].serialize_data is not None
assert courses[0].teiki.serialize_data is not None
assert courses[0].routes[0].lines[0].train_id is not None
assert courses[0].pass_statuses[0].name is not None
assert courses[0].pass_statuses[0].kind is not None
assert courses[0].prices[0].kind == "ChargeSummary"
assert courses[0].routes[0].distance == 58
assert courses[0].routes[0].exhaust_co2 == 116
定期券の払い戻し計算
定期券の払い戻し計算APIを実行します。検索条件、結果は定期券の払い戻し計算 - 駅すぱあと API Documents 駅データ・経路検索のWebAPIを参照してください。
query = client.courseRepaymentQuery()
query.serializeData = '1,true'
query.checkEngineVersion = False
query.serializeData = 'VkV4QaECp9nIAsMCpgEz76YDpgEz76UEkcIBQwAAAAKmATPvpQPKAQECAQMBBAEHAQgBCgIPQv9_EKX_9xSRpVjVBZfBAqVYj8ECpVjVwQKlWXvBAqVZLMECpVkPwQKlWvHBAqVXwAaSwwEBAgEDxwGlWFoCDQMPBQMGRDk0NlQHBAgDwwEBAgEDxgGmAAIwMwIVAxYFAwcGCAUHksUBpgEz76gDpQJfBKUCZgUACADGAaYBM||oAgEDpQJwBKUCcQUACAAIksQEAQUBB6RtCAHGAgEEAgUBBgEHpQEvCAIJksEDAcMBAQIBAwEPkcUBkwABAgKSwwEAAgADAMMBAQIBAwEDksMBAAIAAwDDAQECAQMBBJIAAQWSAAA*--T3221233232319:F332112212000:A23121141:--88eed71f6168dfe5ab30b8cc5e938621dd3806a7--0--0--0--284'
results = query.execute()
assert results['repayment_list'] is not None
assert results['teiki_route'] is not None
assert results['repayment_list'].repayment_date is not None
assert results['repayment_list'].repayment_tickets is not None
assert results['repayment_list'].repayment_tickets[0].fee_price_value is not None
assert results['teiki_route'].section_separator is not None
assert results['teiki_route'].teiki_route_sections is not None
assert results['teiki_route'].teiki_route_sections[0].points is not None
assert results['teiki_route'].teiki_route_sections[0].points[0].station.name is not None
assert results['teiki_route'].teiki_route_sections[0].points[0].prefecture is not None
緯度経度からの周辺駅検索
query = client.geoStationQuery()
query.set_geo_point(langitude="35.6783055555556", longitude="139.770441666667", radius=1000, geodetic='tokyo')
# または
query.set_geo_point(langitude="35.6783055555556", longitude="139.770441666667", radius=1000)
# または
query.set_geo_point(langitude="35.6783055555556", longitude="139.770441666667", geodetic='tokyo')
# または
query.set_geo_point(langitude="35.6783055555556", longitude="139.770441666667")
points = query.execute()
assert(len(points) > 0)
assert(isinstance(points[0], Point))
assert(points[0].station.name is not None)
assert(points[0].prefecture is not None)
assert(points[0].prefecture.name is not None)
assert(points[0].prefecture.code is not None)
print(points[0].distance)
print(points[0].station.name)
print(points[0].prefecture)
print(points[0].prefecture.name)
print(points[0].prefecture.code)
ライセンス
MITライセンスです。
Metadata
Release files for ekispert 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ekispert-0.5.0.tar.gz | 66.6 kB | Without provenance | Details for ekispert-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ekispert-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for ekispert-0.5.0-py3-none-any.whl |
Total release size: 235.1 kB
Release files / ekispert-0.5.0.tar.gz
| Download URL | ekispert-0.5.0.tar.gz |
|---|---|
| Size | 66.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
24d1dbb08063f9432a47e25556dc2122a334c79acf353cfb2e412db745d1b331
|
|
BLAKE2b-256 checksum How to use checksums |
8280c4bd688f95a4b5642374c47f125c35613a8da53a8d5cc0ff0e8521454ad9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.11
|
Release files / ekispert-0.5.0-py3-none-any.whl
| Download URL | ekispert-0.5.0-py3-none-any.whl |
|---|---|
| Size | 168.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5726cf483ce663df575cfc45e96e4d459c55c20bb877c5760a1b375a61795758
|
|
BLAKE2b-256 checksum How to use checksums |
5ebe3ea8829f664cfa600f9cec90b8e3e3996d8638b90e524ecf50590bba7179
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.11
|
Security for ekispert 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.