Skip to content
API documentation
Create profile

Creating profiles

Create 5 profiles (POST /profile/os_type/create).

Code

import requests
import json
 
def create_profile(local_api_token, local_api_port, os_type, profile_name):
url = f'http://localhost:{local_api_port}/profile/{os_type}/create'
headers = {
'x-api-key': local_api_token
}
body = {
'name': profile_name
}
 
    response = requests.post(url, headers=headers, json=body)
 
    if response.status_code == 202:
        return response.json()
    else:
        return {'error': 'Unable to fetch data', 'status_code': response.status_code}
 
local_api_token = 'FA70fE'
local_api_port = 56789
 
os_type = 'macOS'
 
# os_type = 'Windows'
 
# Create 5 MacOS profiles
 
for i in range(0, 5):
profile_name = f'w-{i}'
profile = create_profile(local_api_token, local_api_port, os_type, profile_name) # Creating of profile return structure with \_ID # You can connect profile ID with proxy, mark with tag, start, use with Selenium
print(json.dumps(profile, indent=3))
 

This script will create 5 new profiles in a loop. And will print 5 times the Local API response.

Example of an answer

{
   "_id": "68812755e2020e781e2011e7",
   "name": "w-0",
   "tags": [],
   "status": 0
}
{
   "_id": "68812756e2020e781e201221",
   "name": "w-1",
   "tags": [],
   "status": 0
}
{
   "_id": "688127578d96bb51aa417592",
   "name": "w-2",
   "tags": [],
   "status": 0
}
{
   "_id": "68812758e2020e781e201295",
   "name": "w-3",
   "tags": [],
   "status": 0
}
{
   "_id": "6881275a8d96bb51aa4175e3",
   "name": "w-4",
   "tags": [],
   "status": 0
}