Skip to main content

Split Python API

This API wrapper is designed to work with Split, the platform for controlled rollouts, serving features to your users via the Split feature flag to manage your complete customer experience.

For specific instructions on how to use Split Admin REST API refer to our official API documentation.

Full documentation on this Python wrapper is available in this link.

Quick setup

Install the split-admin-api:

pip install split-admin-api

Import the client object and initialize connection using an Admin API Key:

from splitapiclient.main import get_client
client = get_client({'apikey': 'ADMIN API KEY'})

Enable optional logging:

import logging
logging.basicConfig(level=logging.DEBUG)

Workspaces

Fetch all workspaces:

for ws in client.workspaces.list():
    print ("\nWorkspace:"+ws.name+", Id: "+ws.id)

Find a specific workspaces:

ws = client.workspaces.find("Defaults")
print ("\nWorkspace:"+ws.name+", Id: "+ws.id)

Environments

Fetch all Environments:

ws = client.workspaces.find("Defaults")
for env in client.environments.list(ws.id):
    print ("\nEnvironment: "+env.name+", Id: "+env.id)

Add new environment:

ws = client.workspaces.find("Defaults")
env = ws.add_environment({'name':'new_environment', 'production':False})

Splits Fetch all Splits:

ws = client.workspaces.find("Defaults")
for split in client.splits.list(ws.id):
    print ("\nSplit: "+split.name+", "+split._workspace_id)

Add new Split:

split = ws.add_split({'name':'split_name', 'description':'new UI feature'}, "user")
print(split.name)

Add tags:

split.associate_tags(['my_new_tag', 'another_new_tag'])

Add Split to environment:

ws = client.workspaces.find("Defaults")
split = client.splits.find("new_feature", ws.id) 
env = client.environments.find("Production", ws.id)
tr1 = treatment.Treatment({"name":"on","configurations":""})
tr2 = treatment.Treatment({"name":"off","configurations":""})
bk1 = bucket.Bucket({"treatment":"on","size":50})
bk2 = bucket.Bucket({"treatment":"off","size":50})
match = matcher.Matcher({"attribute":"group","type":"IN_LIST_STRING","strings":["employees"]})
cond = condition.Condition({'matchers':[match.export_dict()]})
rl = rule.Rule({'condition':cond.export_dict(), 'buckets':[bk1.export_dict(), bk2.export_dict()]})
defrl = default_rule.DefaultRule({"treatment":"off","size":100}) 
data={"treatments":[tr1.export_dict() ,tr2.export_dict()],"defaultTreatment":"off", "baselineTreatment": "off","rules":[rl.export_dict()],"defaultRule":[defrl.export_dict()], "comment": "adding split to production"}
splitdef = split.add_to_environment(env.id, data)

Kill Split:

ws = client.workspaces.find("Defaults")
env = client.environments.find("Production", ws.id)
splitDef = client.split_definitions.find("new_feature", env.id, ws.id)
splitDef.kill()

Restore Split:

splitDef.restore()

Fetch all Splits in an Environment:

ws = client.workspaces.find("Defaults")
env = client.environments.find("Production", ws.id)
for spDef in client.split_definitions.list(env.id, ws.id):
    print(spDef.name+str(spDef._default_rule))

Submit a Change request to update a Split definition:

splitDef = client.split_definitions.find("new_feature", env.id, ws.id)
definition= {"treatments":[ {"name":"on"},{"name":"off"}],
    "defaultTreatment":"off", "baselineTreatment": "off",
    "rules": [],
    "defaultRule":[{"treatment":"off","size":100}],"comment": "updating default rule"
}
splitDef.submit_change_request(definition, 'UPDATE', 'updating default rule', 'comment', ['user@email.com'], '')

List all change requests:

for cr in client.change_requests.list():
    if cr._split is not None:
        print (cr._id+", "+cr._split['name']+", "+cr._title+", "+str(cr._split['environment']['id'])) 
    if cr._segment is not None:
        print (cr._id+", "+cr._segment['name']+", "+cr._title)

Approve specific change request:

for cr in client.change_requests.list():
    if cr._split['name']=='new_feature':
        cr.update_status("APPROVED", "done")

Users and Groups

Fetch all Active users:

for user in client.users.list('ACTIVE'):
    print(user.email+", "+user._id) 

Invite new user:

group = client.groups.find('Administrators')
userData = {'email':'user@email.com', 'groups':[{'id':'', 'type':'group'}]}
userData['groups'][0]['id'] = group._id
client.users.invite_user(userData)

Delete a pending invite:

for user in client.users.list('PENDING'):
    print(user.email+", "+user._id+", "+user._status)
    if user.email == 'user@email.com': 
        client.users.delete(user._id)

Update user info:

data = {'name':'new_name', 'email':'user@email.com', '2fa':False, 'status':'ACTIVE'}
user = client.users.find('user@email.com')
user.update_user(user._id, data)

Fetch all Groups:

for group in client.groups.list():
    print (group._id+", "+group._name)

Create Group:

client.groups.create_group({'name':'new_group', 'description':''})

Delete Group:

group = client.groups.find('new_group')
client.groups.delete_group(group._id)

Replace existing user group:

user = client.users.find('user@email.com')
group = client.groups.find('Administrators')
data = [{'op': 'replace', 'path': '/groups/0', 'value': {'id': '<groupId>', 'type':'group'}}]
data[0]['value']['id'] = group._id
user.update_user_group(data)

Add user to new group

user = client.users.find('user@email.com')
group = client.groups.find('Administrators')
data = [{'op': 'add', 'path': '/groups/-', 'value': {'id': '<groupId>', 'type':'group'}}]
data[0]['value']['id'] = group._id
user.update_user_group(data)

Commitment to Quality:

Split’s APIs are in active development and are constantly tested for quality. Unit tests are developed for each wrapper based on the unique needs of that language, and integration tests, load and performance tests, and behavior consistency tests are running 24/7 via automated bots. In addition, monitoring instrumentation ensures that these wrappers behave under the expected parameters of memory, CPU, and I/O.

About Split:

Split is the leading platform for intelligent software delivery, helping businesses of all sizes deliver exceptional user experiences, and mitigate risk, by providing an easy, secure way to target features to customers. Companies like WePay, LendingTree and thredUP rely on Split to safely launch and test new features and derive insights on their use. Founded in 2015, Split's team comes from some of the most innovative enterprises in Silicon Valley, including Google, LinkedIn, Salesforce and Splunk. Split is based in Redwood City, California and backed by Accel Partners and Lightspeed Venture Partners. To learn more about Split, contact hello@split.io, or start a 14-day free trial at www.split.io/trial.

Try Split for Free:

Split is available as a 14-day free trial. To create an account, visit split.io/trial.

Learn more about Split:

Visit split.io/product for an overview of Split, or visit our documentation at docs.split.io for more detailed information.

System Status:

We use a status page to monitor the availability of Split’s various services. You can check the current status at status.split.io.

Metadata

Release files for splitapiclient 3.0.2

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

Source distribution (sdist)

Source distribution for splitapiclient 3.0.2
File Size Uploaded Provenance Actions
splitapiclient-3.0.2.tar.gz 40.8 kB Without provenance Details for splitapiclient-3.0.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for splitapiclient 3.0.2
File Interpreter ABI Platform Actions
splitapiclient-3.0.2-py3.8.egg Legacy Egg format - - Details for splitapiclient-3.0.2-py3.8.egg
splitapiclient-3.0.2-2-py3.8.egg Legacy Egg format - - Details for splitapiclient-3.0.2-2-py3.8.egg

Total release size: 183.0 kB

Release files / splitapiclient-3.0.2.tar.gz

Download URL splitapiclient-3.0.2.tar.gz
Size 40.8 kB
Tags Source
SHA-256 checksum
How to use checksums
10e79b403cee188200779166d894864d76eb04a254897039eb149f5cf37ca5e9
BLAKE2b-256 checksum
How to use checksums
344215081f33b955caf51fd7b347da5538b2f0c45d5a72a733aa32c2cbeda765
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

Release files / splitapiclient-3.0.2-py3.8.egg

Download URL splitapiclient-3.0.2-py3.8.egg
Size 71.1 kB
Tags Egg
SHA-256 checksum
How to use checksums
a9fe81d231159b7b4b9adef19b00dc2d91390d4b9032e0b84feffca5aea4ceeb
BLAKE2b-256 checksum
How to use checksums
89ffb9860ba50099a5022241522a907ad9fe7fd672d2fb850e4d0b1e62c67f45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

Release files / splitapiclient-3.0.2-2-py3.8.egg

Download URL splitapiclient-3.0.2-2-py3.8.egg
Size 71.1 kB
Tags Egg
SHA-256 checksum
How to use checksums
8e462f5dfd6722c15569abe27d9588f1c5b68020b13bccf806a19d6a4324d4ab
BLAKE2b-256 checksum
How to use checksums
2e8dd48024ccfdfce13ea2e0b67f0f443c8a8f6b6e395028fab0492de0950d5d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9

Security for splitapiclient 3.0.2

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

3.0.2 This release

3 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