Unofficial Python API for Interpals.net.
Project description
interpals-api
This Python library provides a simple HTTP API for working with the website https://interpals.net/. It includes:
- retrieving data by user identifier
- listing visitors
- searching for users by criterions
- viewing and sending messages, deleting chats
- listing, adding and removing friends
- listing albums and pictures
Installation
pip install interpals-api
Basic example
from interpals_api import Session, Api
session = Session.login('yourusername', 'yourpassword')
api = Api(session)
user_info = api.profile('someuser')
print(user_info)
Since version 2.1 it supports asynchronous calls for each api method. Below there is a brief asynchonous example:
from interpals_api import SessionAsync, ApiAsync
session = await SessionAsync.login('yourusername', 'yourpassword')
api = ApiAsync(session)
user_info = await api.profile('someuser')
print(user_info)
Other examples
Basic example to retrieve user info:
from interpals_api import Session, Api
session = Session.login('yourusername', 'yourpassword')
api = Api(session)
# This gives info of the user with the link: https://www.interpals.net/someuser
user_info = api.profile('someuser')
Dump and load session object:
from interpals_api import Session, Api
session = Session.login('yourusername', 'yourpassword')
# Save session into a file
with open('session.json', 'w') as f:
session.dump(f)
# Load session from the saved file
with open('session.json') as f:
session = Session.load(f)
Viewing and searching for users:
from interpals_api import Session, Api
session = Session.login('yourusername', 'yourpassword')
api = Api(session)
# Viewing a certain user
api.view('someuser')
# Showing the visitors of your profile
users = api.visitors()
print(users)
# Searching for users
options = {
'age1': '20',
'age2': '40',
'sex': ['male', 'female'],
'continents': ['AF', 'AS', 'EU', 'NA', 'OC', 'SA'],
'countries': ['US', 'CA', 'UK', 'RU'],
'keywords': 'travelling',
'online': True,
'cityName': 'London' # Or you can use 'city' with its direct code on the website (it's faster)
}
for user in api.search(options, limit=100, timeout=1.0):
print(user)
To work with friends and pictures, it is necessary to use uid in methods:
from interpals_api import Session, Api
session = Session.login('yourusername', 'yourpassword')
api = Api(session)
uid = api.get_uid('someuser')
# Listing friends of the user 'someuser'
friends = api.friends(uid)
print(friends)
# Adding 'someuser' to friends
api.friend_add(uid)
# Removing 'someuser' from friends
api.friend_remove(uid)
# Listing pictures
albums = api.albums(uid)
for album in albums:
aid = album['aid']
pictures = api.pictures(uid, aid)
for picture in pictures:
print(picture['src'])
Working with the chat is done through thread_id:
from interpals_api import Session, Api
session = Session.login('yourusername', 'yourpassword')
api = Api(session)
uid = api.get_uid('someuser')
# Listing your chats
result = api.chat(count=9, offset=0)
print(result['chats'])
# Staring new chat (getting thread_id)
thread_id = api.get_thread_id(uid)
# Show chat messages
messages = api.chat_messages(thread_id)
print(messages)
# Send new message to the thread
api.chat_send(thread_id, "Hey! How are you?")
# Removing chat
api.chat_delete(thread_id)
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
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 interpals_api-2.3.0.tar.gz.
File metadata
- Download URL: interpals_api-2.3.0.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c6a941799fa7074d207a5d0c4cfc201c31cbed46d9517abb46218a9f39c882e
|
|
| MD5 |
a80e30dd707c9d493a116dbe135ef9c8
|
|
| BLAKE2b-256 |
b00e1e77f3bbf9b3bacede4b96b39f367024739f92912d0effabcbe5b66f6759
|
File details
Details for the file interpals_api-2.3.0-py3-none-any.whl.
File metadata
- Download URL: interpals_api-2.3.0-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0933bf04d6604dcbb8dc244ab2e7d4024345c48b5ee6429e42a271429c527ea
|
|
| MD5 |
61f85f07f592013ed205c17c8768cd49
|
|
| BLAKE2b-256 |
240fa262e01842c753f28f15c68019970f089f6a16efae2891aa80a5a11f65d4
|