Persistent profiles
This tutorial will show you how to work with Surfsky cloud browser persistent profiles.
Create persistent profile
In order to create persistent profile you have to provide it's title and target operating system (win or mac). It is optional to provide proxy or open vpn config, but if not provided you have to define it on every start. Checkout api docs for more info.
- Python
- JavaScript
import os
import httpx
API_TOKEN = os.environ['API_TOKEN']
PROXY = os.environ['PROXY']
async def create_persistent_profile():
async with httpx.AsyncClient(
base_url='https://api-public.surfsky.io',
headers={'X-Cloud-Api-Token': API_TOKEN},
timeout=60.0,
) as client:
create_profile_resp = await client.post(
'/profiles',
json={
'title': 'Test profile',
'fingerprint': {'os': 'win'},
'proxy': PROXY,
},
)
create_profile_resp.raise_for_status()
return {'uuid': create_profile_resp.json()['data']['uuid']}
const axios = require('axios')
const API_TOKEN = process.env.API_TOKEN
const PROXY = process.env.PROXY
const SURFSKY_API = axios.create({
baseURL: 'https://api-public.surfsky.io',
timeout: 100000,
})
async function createPersistentProfile() {
const response = await SURFSKY_API.post(
'/profiles',
{
title: 'Test profile',
fingerprint: { os: 'win' },
proxy: PROXY,
},
{ headers: { 'X-Cloud-Api-Token': API_TOKEN } }
)
return response.data.uuid
}
Start persistent profile
To start persistent profile you have to make POST request to profile specific url. In case proxy or vpn config was provided on creation you don't have to specify it on start, otherwise proxy or open vpn config is required. Checkout api docs for more info.
- Python
- JavaScript
import os
import httpx
API_TOKEN = os.environ['API_TOKEN']
PROFILE_UUID = os.environ['PROFILE_UUID']
async def start_persistent_profile():
async with httpx.AsyncClient(
base_url='https://api-public.surfsky.io',
headers={'X-Cloud-Api-Token': API_TOKEN},
timeout=60.0,
) as client:
browser_data_resp = await client.post(f'/profiles/{PROFILE_UUID}/start')
browser_data_resp.raise_for_status()
return browser_data_resp.json()
const axios = require('axios')
const API_TOKEN = process.env.API_TOKEN
const PROFILE_UUID = process.env.PROFILE_UUID
const SURFSKY_API = axios.create({
baseURL: 'https://api-public.surfsky.io',
timeout: 100000,
})
async function startPersistentProfile() {
const response = await SURFSKY_API.post(
`/profiles/${PROFILE_UUID}/start`,
{},
{ headers: { 'X-Cloud-Api-Token': API_TOKEN } }
)
return response.data.uuid
}