Client to call UR Chintai API (UR都市機構)
Project description
urchintai-client Package
This is a simple client for UR Chintai API (UR都市機構) written in Python.
Please see my blog post at the link below for more information regarding the API.
https://duongnt.com/urchintai-api
Install
You can install urchintai-client using pip, just run the following command in the command line.
pip install urchintai-client
Usage
Note: all calls to remote API are executed asynchronously.
Create client object
from urchintai_client.request_sender import RequestSender
# Create your aiohttp session object, we will call it sess
sender = RequestSender(sess) # this object is used to send request to and receive response from API
client = UrClient(sender)
You can choose to create and use your own aiohttp session, or you can use this helper class to create and manager session.
from urchintai_client.session_manager import SessionManager
sess = SessionManager.GetSession()
In this case you can call the following method to close the session and release resource.
await SessionManager.CloseSession()
Check if a property has vacant room(s)
Call is_property_vacant method and pass the URL of the property you want to check.
url = 'https://www.ur-net.go.jp/chintai/kanto/kanagawa/40_2460.html'
is_vacant = await client.is_property_vacant(url)
If you know the property code, you can use it to check for vacancy.
property_code = {
'store_code': '40',
'house_code': '246',
'type': '0'
}
is_vacant = await client.is_property_vacant(property_code)
Find the name of a property
Call get_property_name method and pass the URL of the property.
url = 'https://www.ur-net.go.jp/chintai/kanto/kanagawa/40_2460.html'
name = await client.get_property_name(url)
Check if a room is vacant
Call is_room_vacant method and pass the URL of the room you want to check.
url = 'https://www.ur-net.go.jp/chintai/kanto/kanagawa/40_2460_room.html?JKSS=000020654'
is_vacant = await client.is_room_vacant(url)
If you know the room code, you can use it to check for vacancy.
room_code = {
'store_code': '40',
'house_code': '246',
'type': '0',
'room_id': '000020654'
}
is_vacant = await client.is_room_vacant(room_code)
Run test from terminal
Below is how we run get_property_name from python terminal. It should work as is as long as all dependencies are installed.
import asyncio
from urchintai_client.session_manager import SessionManager
from urchintai_client.request_sender import RequestSender
from urchintai_client.ur_client import UrClient
sender = RequestSender(SessionManager.GetSession())
client = UrClient(sender)
url = 'https://www.ur-net.go.jp/chintai/kanto/kanagawa/40_2460.html'
loop = asyncio.get_event_loop()
name = loop.run_until_complete(client.get_property_name(url))
print(f'Property name: {name}')
loop.run_until_complete(SessionManager.CloseSession()) # Don't forgot to close the session
This should print the following message to console.
Property name: 西久保町公園ハイツ
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file urchintai-client-1.0.0.tar.gz.
File metadata
- Download URL: urchintai-client-1.0.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1199f9cbbfc5e979cd1cd0a4eb87fb8f617533d69ab4c2d530ef0b6748badf8e
|
|
| MD5 |
f05678f711147d8aa0d53ae46e2b9072
|
|
| BLAKE2b-256 |
61de11f3604ae9264f6750525763442d531735882a20ec8cd26587cd605359c8
|
File details
Details for the file urchintai_client-1.0.0-py3-none-any.whl.
File metadata
- Download URL: urchintai_client-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7655177836b6006f65be0f3491e4b8714d920060f0e3e52718c1c795b84a4878
|
|
| MD5 |
edb92601900f4183919ad19582f9b4c2
|
|
| BLAKE2b-256 |
e116ffc26fc3393220d1c6ee2120f83377c3e586912b218189ca68a26bc87abe
|