Skip to main content

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)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

interpals_api-2.3.1.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

interpals_api-2.3.1-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file interpals_api-2.3.1.tar.gz.

File metadata

  • Download URL: interpals_api-2.3.1.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for interpals_api-2.3.1.tar.gz
Algorithm Hash digest
SHA256 81efe569675c792d2d50a0b86dc6d8febd80104a0a50f90d2b2df587fd6de0ac
MD5 6752759aa6c8cb8f33fb835e34ffcfbc
BLAKE2b-256 df0843e5fba9264d9fe3275c21f13c3619fcfa71dcb3f235919f2fd1878294a2

See more details on using hashes here.

File details

Details for the file interpals_api-2.3.1-py3-none-any.whl.

File metadata

  • Download URL: interpals_api-2.3.1-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

Hashes for interpals_api-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e632018880aa005c5a069fb64de990ca9b2936197917c531f4115b7db0e9193
MD5 e4ea7564c7f48a65fba1bfebb877c53d
BLAKE2b-256 6c009ec5b0f51ab39c0b850ef4b4a54b68d7aafbe9e11a9379215af940849986

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.3.1 This release

2 files

2.3.0

2 files

2.2.1

1 file

2.2.0

1 file

2.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page