RIPE Database REST API Client for Python
Project description
PyRipe
A modern Python client library for the RIPE Database REST API. PyRipe provides a clean, type-safe interface to interact with RIPE's RESTful web services, built with Pydantic for robust data validation and serialization.
Features
- Full REST API Coverage: Support for all RIPE Database operations including search, create, update, and delete
- Type Safety: Built with Pydantic models for compile-time type checking and runtime validation
- Dual Environment Support: Seamless switching between production (RIPE) and test environments
- Rich Query Options: Advanced search capabilities with filtering, tagging, and flags
- Error Handling: Comprehensive exception handling with detailed error messages
- Modern Python: Requires Python 3.13+ and uses type hints throughout
Installation
pip install pyripe
Or using Poetry:
poetry add pyripe
Quick Start
Initialize the Client
from pyripe import RipeRestApiClient
# Use RIPE production environment
client = RipeRestApiClient(source="RIPE")
# Or use test environment
client = RipeRestApiClient(source="TEST")
# With basic authentication
client = RipeRestApiClient(source="RIPE", basic_auth="your_base64_auth")
Search Objects
# Simple search
result = client.search("192.168.1.1")
# Advanced search with filters
result = client.search(
query="192.168.1.1",
sources=["RIPE"],
type_filters=["inetnum", "route"],
limit=10,
offset=0
)
Get Object by Primary Key
from pyripe.models import Attributes, Attribute
# Define the primary key attributes
pk = Attributes(attribute=[
Attribute(name="inetnum", value="192.168.1.0 - 192.168.1.255")
])
# Get the object
result = client.get_object(pk)
Create a New Object
from pyripe.models import Object, Attributes, Attribute
# Create a new object
new_obj = Object(
attributes=Attributes(attribute=[
Attribute(name="inetnum", value="192.168.2.0 - 192.168.2.255"),
Attribute(name="netname", value="MY-NETWORK"),
# Add more attributes...
])
)
result = client.create_object(new_obj)
Update an Object
# Update existing object
updated_obj = Object(
attributes=Attributes(attribute=[
Attribute(name="inetnum", value="192.168.2.0 - 192.168.2.255"),
Attribute(name="netname", value="MY-UPDATED-NETWORK"),
])
)
result = client.update_object(updated_obj)
Delete an Object
# Delete object by primary key
pk = Attributes(attribute=[
Attribute(name="inetnum", value="192.168.2.0 - 192.168.2.255")
])
result = client.delete_object(pk)
Supported Object Types
PyRipe supports all RIPE Database object types:
Primary Objects
aut-num- Autonomous System Numberdomain- Domain nameinet6num- IPv6 address rangeinetnum- IPv4 address rangeroute- IPv4 routeroute6- IPv6 routeas-set- AS setfilter-set- Filter setinet-rtr- Internet routerpeering-set- Peering setroute-set- Route setrtr-set- Router set
Secondary Objects
as-block- AS blockirt- Incident Response Teamkey-cert- Key certificatemntner- Maintainerorganisation- Organizationperson- Personrole- Rolepoem- Poempoetic-form- Poetic form
API Reference
RipeRestApiClient
The main client class for interacting with the RIPE REST API.
Methods
get_object(pk, unfiltered=False, managed_attributes=False, abuse_contact=False, resource_holder=False)- Retrieve a specific objectsearch(query, sources=[], inverse_attributes=None, include_tags=None, exclude_tags=None, type_filters=None, flags=None, managed_attributes=False, abuse_contact=False, resource_holder=False, limit=None, offset=None)- Search for objectscreate_object(obj)- Create a new objectupdate_object(obj)- Update an existing objectdelete_object(pk)- Delete an object
Data Models
All API responses and requests use Pydantic models for type safety and validation:
WhoisResources- Main response containerObject- RIPE database objectAttributes- Object attributesAttribute- Individual attribute- And many more...
Error Handling
PyRipe provides specific exception types for different error scenarios:
from pyripe.exceptions import (
RipeRestApiError,
RipeRestApiServerError,
RipeRestApiInvalidPrimaryKeyError,
RipeRestApiUnexpectedResponseError
)
try:
result = client.search("invalid-query")
except RipeRestApiServerError as e:
print(f"Server error: {e.http_status}")
print(f"Error messages: {e.ripe_messages}")
except RipeRestApiInvalidPrimaryKeyError:
print("Invalid primary key provided")
except RipeRestApiError as e:
print(f"An error occurred: {e}")
API Endpoints
- Production:
https://rest.db.ripe.net - Test:
https://rest-test.db.ripe.net
For more information about the RIPE REST API, visit the official documentation.
Requirements
- Python 3.13+
- requests >= 2.32.5
- pydantic >= 2.12.5
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and questions:
Acknowledgments
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 pyripe-0.1.0.tar.gz.
File metadata
- Download URL: pyripe-0.1.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.9.1 Darwin/25.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f32af3ca9330e5017007c1492f5840a49f29776b715d92db2c5cc1da47a1ae7c
|
|
| MD5 |
5693455af8d07d1681c7ab6e99d7148f
|
|
| BLAKE2b-256 |
b9d784565eec3c516d1e13a646f42012450b0a209e2007e37d950116875c9f39
|
File details
Details for the file pyripe-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyripe-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.9.1 Darwin/25.3.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48aef37053b6a92b734fd2cd40979e72ed51d177d37ee195c541b6abf6be5bdc
|
|
| MD5 |
2447cfa8b032dc4cf7998d7354843c24
|
|
| BLAKE2b-256 |
144d1aefe63e9d796f57d01ebe07ba36f4d4e92ce834aeab73c2be43aba9c3b9
|