Skip to main content

Python SDK

Version

For our official developer documentation, visit our developer site

Description

This repository is a Python SDK that wraps the Rebrandly API.

Installation

pip install rebrandly-sdk

Local Development and Testing

Create a .env.development or .env.test file with the below code and populate the values:

API_KEY='YOUR_API_KEY'
EXTENDED_WORKSPACE_ID='YOUR_EXTENDED_WORKSPACE_ID'
EXTENDED_WORKSPACE_DOMAIN_ID='YOUR_EXTENDED_WORKSPACE_DOMAIN_ID'
IOS_APP_ID='YOUR_IOS_APP_ID'
ANDROID_APP_ID='YOUR_ANDROID_APP_ID'

Export your ENVIRONMENT variable before running tests so test files know which .env file to load. If the ENVIRONMENT variable is not specified, the default file to be loaded is .env.development.

Authentication

This SDK supports authentication via API key. You can create an API key in your Rebrandly dashboard. The API key should be specified when creating a RebrandlyClient instance.

from src.rebrandly_client import RebrandlyClient

client = RebrandlyClient('YOUR_API_KEY')

Usage

Create a link:

client = RebrandlyClient('YOUR_API_KEY')
new_link = client.links.create('https://destination_url_...')

Create conditional traffic routing rule:

link_id = client.links.create('https://www.rebrandly.com')['id']
route = {
    "destination":'https://www.rebrandly.com/enterprise-security',
    "condition":
        {"and":[{"property":"req.country","operator":"in","values":["ie"]}]}
    }
client.links.create_route(link_id, route)

Create link OpenGraph:

link_id = client.links.create(destination_url_google)['id']
client.links.set_opengraph(link_id, 'What is Rebrandly', image_url='https://rebrandly.com/example.jpg', object_type='website')

Create deep link:

link_id = client.links.create('https://wwww.rebrandly.com')['id']
path = {"path":"/watch?apex=&ios_scheme=&v=3VmtibKpmXI"}
client.links.create_deep_link(link_id, 'YOUR-APP-ID-HERE', path)

Manage workspaces:

# Create a workspace
workspace = client.workspaces.create('My Workspace', 'classic')

# List workspaces
workspaces = client.workspaces.list()

# Update a workspace
client.workspaces.update(workspace['id'], name='Renamed Workspace')

# Delete a workspace
client.workspaces.delete(workspace['id'])

Pagination

This SDK supports pagination for requests that return many results. When a method that supports pagination is called, a PaginatedResponse instance will be returned. A PaginatedResponse is an iterable object that supports a next() function to retrieve the next batch of results. Here is a code snippet for how to work with a method that supports pagination. In the example below, it will list all links and aggregate those links into an array called all_links.

    page_of_links = client.links.list()
    all_links = []
    while page_of_links.current_items_count > 0:
        for link in page_of_links:
            all_links.append(link)
        page_of_links.next()

Design Patterns

Create and Update vs Set

Create methods will create a new resource. Update methods will update an existing resource. Set methods will create a resource or overwrite the existing resource if one already exists.

License

Rebrandly Python SDK is released under the MIT License.

Metadata

Release files for rebrandly-official 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rebrandly-official 0.1.0
File Size Uploaded Provenance
rebrandly_official-0.1.0.tar.gz 10.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for rebrandly-official 0.1.0
File Interpreter ABI Platform
rebrandly_official-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.2 kB

Release files / rebrandly_official-0.1.0.tar.gz

Download URL rebrandly_official-0.1.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0c6aae394c005f184c0784ad19ab1c59fe745ae4be2ca1a347c19cf50b03f846
BLAKE2b-256 checksum
How to use checksums
e0258e9500ed1d9bcac75696c3bcebf44de278cd6758a03f27b7e25fc115b2f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.13

Release files / rebrandly_official-0.1.0-py3-none-any.whl

Download URL rebrandly_official-0.1.0-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b85a55d62dc6e64dfd2c3ca33b5af592ec8052af7b6e470e9e13e2216f10f62f
BLAKE2b-256 checksum
How to use checksums
447e3433bd988ad0b0ef4c0a2daa433996ec28a3b4f87e9419c06a0715c55a2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.13

Security for rebrandly-official 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page