### Example Usage: Get Proxy and User Balance - TypeScript Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetOnlineProxy.md Demonstrates fetching a specific proxy by ID and then retrieving the user's balance. Initializes the API client with an API key, language, and account ID. ```typescript const driver = new OnlineProxyAPI('APIKEY', 'en', 123); driver.getProxy('proxy_id').then((proxy) => { console.log('Proxy:', proxy); }); driver.getUserBalance().then((balance) => { console.log('Balance:', balance); }); ``` -------------------------------- ### Initialize OnlineSimDriver and Get Proxy Methods Source: https://github.com/s00d/onlinesim-js-api/wiki/GetProxy Initializes the OnlineSimDriver with an API key and demonstrates how to access proxy-related methods. Use this to start interacting with the proxy API. ```javascript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.proxy() ``` -------------------------------- ### Install onlinesim-js-api Source: https://github.com/s00d/onlinesim-js-api/wiki/Home Install the package using npm. This is a prerequisite for using the API. ```bash npm install onlinesim-js-api ``` -------------------------------- ### Example Usage of User Methods Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetUser.md A general example demonstrating how to initialize the OnlineSimDriver and access user-related methods like balance. This serves as a basic template for other user operations. ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.user(); ggetter.balance().then((result) => { console.log(result); }); ``` -------------------------------- ### Install Onlinesim JS API with yarn Source: https://github.com/s00d/onlinesim-js-api/blob/master/README.md Install the package in your project using yarn. ```bash yarn add onlinesim-js-api ``` -------------------------------- ### Install Onlinesim JS API with pnpm Source: https://github.com/s00d/onlinesim-js-api/blob/master/README.md Install the package in your project using pnpm. ```bash pnpm install onlinesim-js-api ``` -------------------------------- ### Initialize OnlineSimDriver and Get Forwarding Instance Source: https://github.com/s00d/onlinesim-js-api/wiki/GetForward Initializes the OnlineSimDriver with an API key and obtains an instance for managing forwarding operations. This is the starting point for all forwarding-related actions. ```javascript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.forward() ``` -------------------------------- ### Get and State Proxy Information Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetProxy.md Demonstrates fetching general proxy information and its current state. The `get` method retrieves details, while `state` fetches the proxy's status. `stateOne` can be used with a specific tzid. ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.proxy(); getter.get().then((result) => { console.log(result); }); getter.state().then((result) => { console.log(result); }); // or getter.stateOne(res.tzid).then((result) => { console.log(result); }); ``` -------------------------------- ### Get New Proxy and Check Status Source: https://github.com/s00d/onlinesim-js-api/wiki/GetProxy Retrieves a new proxy and then checks its status. The 'get' method fetches a proxy, and 'state' or 'stateOne' can be used to query its status. ```javascript getter.get().then((result) => { console.log(result); }) getter.state().then((result) => { console.log(result); }) ``` ```javascript getter.stateOne(res.tzid).then((result) => { console.log(result); }) ``` -------------------------------- ### Initialize OnlineSimDriver and Rent Object Source: https://github.com/s00d/onlinesim-js-api/wiki/GetRent Demonstrates how to initialize the OnlineSimDriver with an API key and obtain a rent object for subsequent operations. This is the starting point for most rent-related actions. ```javascript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.rent() ``` -------------------------------- ### Get Proxy List Source: https://github.com/s00d/onlinesim-js-api/wiki/GetProxy Retrieves a list of available proxies. ```APIDOC ## state ### Description Get proxy list ### Method GET (implied by usage in example) ### Endpoint /getstate35 ### Parameters #### Query Parameters - **$orderby** (string) - Optional - ASC or DESC (default: no) ### Request Example ```js const driver = new OnlineSimDriver('APIKEY'); const getter = driver.proxy() getter.state().then((result) => { console.log(result); }) ``` ### Response #### Success Response (200) - **result** (array) - List of proxies ``` -------------------------------- ### OnlineSimDriver Numbers API Usage Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetNumbers.md Demonstrates initializing the OnlineSimDriver and using the numbers getter to interact with various number-related API endpoints. Includes examples for fetching tariffs, getting a specific number, checking the state of numbers, and retrieving the next message. ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.numbers(); ggetter.tariffs().then((result) => { console.log(result); }); ggetter.get('3223').then((result) => { console.log(result); }); ggetter.state().then((result) => { console.log(result); }); // or ggetter.stateOne(res.tzid).then((result) => { console.log(result); }); // next message ggetter.next(res.tzid).then((result) => { console.log(result); }); ggetter.state().then((result) => { console.log(result); }); ggetter.close(res.tzid).then((result) => { console.log(result); }); ``` -------------------------------- ### Initialize OnlineSimDriver and GetFree Source: https://github.com/s00d/onlinesim-js-api/wiki/GetFree Initializes the OnlineSimDriver with an API key and creates a getter for free services. This is the starting point for using the GetFree methods. ```javascript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.free() ``` -------------------------------- ### Initialize OnlineSimDriver and Get Number Methods Source: https://github.com/s00d/onlinesim-js-api/wiki/GetNumbers Demonstrates how to initialize the OnlineSimDriver with an API key and access various methods for number retrieval and management. Use this to interact with the API for services. ```javascript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.numbers() ``` -------------------------------- ### Get Rent Tariffs Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetRent.md Retrieves a list of available rent tariffs, including details for each country. ```APIDOC ## `tariffs` ### Description Retrieves the rent tariffs. ### Method `tariffs() => Promise<{ [code: string]: Tariff }>` ### Request Example ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.rent(); getter.tariffs().then((result) => { console.log(result); // Output: { code1: { code: 1, enabled: true, name: 'USA', new: false, position: 1, count: { count1: 10 }, days: { days1: 1 }, extend: 1 } } }); ``` ``` -------------------------------- ### get Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetProxy.md Retrieves a new proxy with specified parameters. You can customize the type, connection, count, operator, country, city, port count, and session settings. ```APIDOC ## get ### Description Retrieves a new proxy with specified parameters. ### Method `get(cl?: 'days' | 'traffic', type?: 'shared' | 'sharednowait' | 'private' | 'privatenowait' | 'multiport', connect?: 'https' | 'socks', count?: number, operator?: 'mts' | 'megafon' | 'beeline' | 'tele2' | null, country?: string, city?: string, port_count?: number, session?: boolean)` ### Parameters #### Query Parameters - **cl** (string) - Optional. Default is 'days'. Allowed values: 'days', 'traffic'. - **type** (string) - Optional. Default is 'private'. Allowed values: 'shared', 'sharednowait', 'private', 'privatenowait', 'multiport'. - **connect** (string) - Optional. Default is 'https'. Allowed values: 'https', 'socks'. - **count** (number) - Optional. Default is 1. - **operator** (string | null) - Optional. Default is null. Allowed values: 'mts', 'megafon', 'beeline', 'tele2'. - **country** (string) - Optional. Default is 'any'. - **city** (string) - Optional. Default is 'any'. - **port_count** (number) - Optional. Default is 1. - **session** (boolean) - Optional. Default is true. ### Response #### Success Response (200) - **Get**: An object representing the retrieved proxy with details like type, connection, host, port, credentials, operator, status, country, rent dates, traffic information, and more. ### Request Example ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.proxy(); getter.get('days', 'private', 'https', 1, 'mts', '7', 'any', 1, true).then((result) => { console.log(result); }); ``` ### Response Example ```json { "type": "private", "connect_type": "https", "host": "example.com", "port": 8080, "user": "user", "pass": "pass", "operator": "mts", "status": 1, "country": 7, "rent": "2023-01-01", "comment": "comment", "port_count": 1, "session": true, "city": "any", "traffic": "100MB", "general_traffic": "1GB", "stop_at": "2023-01-01", "check_at": "2023-01-01", "created_at": "2023-01-01", "updated_at": "2023-01-01", "tzid": 123, "time": 1234567890, "days": 1, "hours": 24, "change_ip": true, "change_type": true, "rotate": true } ``` ``` -------------------------------- ### Get Countries Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetFree.md Retrieves a list of available countries supported by the OnlineSIM service. ```APIDOC ## `countries` ### Description Retrieves the list of available countries. ### Method Signature `() => Promise>` ### Parameters None ### Response Example ```json [ { "country": 7, "country_text": "Russia" }, { "country": 1, "country_text": "USA" } ] ``` ``` -------------------------------- ### Get New Proxy Source: https://github.com/s00d/onlinesim-js-api/wiki/GetProxy Retrieves a new proxy based on specified parameters. ```APIDOC ## get ### Description Get new proxy ### Method GET (implied by usage in example) ### Endpoint /getproxy ### Parameters #### Query Parameters - **$class** (string) - Optional - days or traffic - **$type** (string) - Optional - proxy type for days (default: private) - **$connect** (string) - Optional - connection type for days (default: https) - **$count** (integer) - Optional - days count (default: 1) - **$operator** (string) - Optional - operator code - **$country** (integer) - Optional - country (default: 7) - **$city** (string) - Optional - city - **$port_count** (integer) - Optional - port count for muliport (default: 1) - **$session** (boolean) - Optional - session for traffic (default: true) ### Request Example ```js const driver = new OnlineSimDriver('APIKEY'); const getter = driver.proxy() getter.get().then((result) => { console.log(result); }) ``` ### Response #### Success Response (200) - **result** (object) - Contains proxy information ``` -------------------------------- ### Get Service Price Source: https://github.com/s00d/onlinesim-js-api/wiki/GetNumbers Retrieves the price for a specific service in a given country. ```APIDOC ## price ### Description Get service price ### Method GET (Implicit, as part of JS SDK) ### Endpoint (Not directly applicable for SDK method) ### Parameters #### Query Parameters - **$country** (integer) - Optional - Defaults to 7. The country code. - **$service** (string) - Required - The service for which to get the price. See [documentation](https://onlinesim.ru/docs/api/ru#getnum). ``` -------------------------------- ### Get Price for Service/Country Combination Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Fetches the price for acquiring a number for a specific service and country. Returns the price as a string. ```typescript const driver = new OnlineSimDriver('your_apikey_here'); const price = await driver.numbers().price('facebook', 7); console.log('Price:', price); // e.g. "0.50" ``` -------------------------------- ### get Source: https://github.com/s00d/onlinesim-js-api/wiki/GetRent Obtains a new phone number for rent. You can specify the country, the number of rental days, and whether to enable auto-extension. ```APIDOC ## get ### Description Get new rent number ### Parameters #### Query Parameters - **$country** (number) - Optional - Default: 7 - country - **$days** (number) - Optional - Default: 1 - count rent days - **$extension** (boolean) - Optional - Default: false - auto extension ``` -------------------------------- ### Get List of All Available Proxies Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetOnlineProxy.md Retrieve a comprehensive list of all proxies currently available. This is useful for browsing or selecting proxies. ```typescript const driver = new OnlineProxyAPI('APIKEY', 'en', 123); driver.getProxyList().then((result) => { console.log(result); // Output: { proxies: [{ id: 'proxy_id', ip: '127.0.0.1', port: 8080, type: 'HTTP', country: 'USA', city: 'New York', anonymity: 'High', speed: 100, uptime: 99, lastChecked: '2023-01-01', createdAt: '2023-01-01', updatedAt: '2023-01-01', comment: 'Proxy comment' }] } }); ``` -------------------------------- ### get Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetNumbers.md Retrieves a new number for a specific service. Returns the tzid of the obtained number. ```APIDOC ## get ### Description Retrieves a new number for a specific service. ### Method `get(service: string, country?: number, reject?: Array, extension?: boolean): Promise` ### Parameters #### Path Parameters - **service** (string) - Required - The service identifier. - **country** (number) - Optional - The country code. Default is 7. - **reject** (Array) - Optional - Exclusion list. - **extension** (boolean) - Optional - Extension flag. Default is false. ### Request Example ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.numbers(); getter.get('service1', 7, [1, 2], false).then((result) => { console.log(result); // Output: 123 (assuming the tzid is 123) }); ``` ### Response #### Success Response (200) - **tzid** (number) - The transaction ID of the obtained number. ``` -------------------------------- ### Get User Balance Source: https://github.com/s00d/onlinesim-js-api/wiki/GetUser Retrieve the current user balance. Requires the API key to be set during driver initialization. ```javascript const driver = new OnlineSimDriver('APIKEY'); driver.user().balance().then((result) => { console.log(result); }) ``` -------------------------------- ### Get Available Proxies for Order Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetOnlineProxy.md Retrieves the list of proxies available for order, matching the input filtering criteria. ```APIDOC ## getAvailableProxiesForOrder ### Description Retrieves the list of proxies available for order, matching the input filtering criteria. ### Method Signature `() => Promise` ### Parameters None. ### Request Example ```typescript const driver = new OnlineProxyAPI('APIKEY', 'en', 123); driver.getAvailableProxiesForOrder().then((result) => { console.log(result); // Output: { proxies: [{ id: 'proxy_id', ip: '127.0.0.1', port: 8080, type: 'HTTP', country: 'USA', city: 'New York', anonymity: 'High', speed: 100, uptime: 99, lastChecked: '2023-01-01', createdAt: '2023-01-01', updatedAt: '2023-01-01', comment: 'Proxy comment' }] } }); ``` ### Response #### Success Response (AvailableProxies Object) - **proxies** (Array) - An array of proxy objects available for order. - Each proxy object contains the same fields as described in the `getProxy` method. ``` -------------------------------- ### Get Proxy Tariffs Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetProxy.md Retrieves the available tariffs for proxies. Requires an initialized OnlineSimDriver with an API key. ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.proxy(); getter.tariffs().then((result) => { console.log(result); // Output: { days: { config: { type1: { type: 'type1', enabled: true, days: { 1: 10 } } }, operators: ['mts', 'megafon'], connect: ['https', 'socks'] }, traffic: { config: { code1: { name: 'name1', cities: { city1: 'city1' }, operators: { code1: 'operator1' } } }, price: { tariff1: 10 } } } }); ``` -------------------------------- ### Fetch Countries, Numbers, and Messages with Onlinesim JS API Source: https://github.com/s00d/onlinesim-js-api/blob/master/index.html This example demonstrates how to initialize the OnlineSimDriver and fetch country, number, and message data using Vue.js. Ensure the OnlineSimDriver is loaded before this script. ```javascript var driver = new window.OnlineSimDriver('').free() new Vue({ data() { return { countries: {}, numbers: {}, messages: {}, }; }, el: '#example1', methods: { showCoutries: function () { driver.countries().then((res) => { this.countries = res }); }, showNumbers: function (country) { driver.numbers(country).then((res) => { this.numbers = res }); }, showMessages: function (number) { driver.messages(number).then((res) => { this.messages = res }); } }, }); ``` -------------------------------- ### stateOne Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetProxy.md Retrieves a specific proxy using its unique tzid. This allows you to get detailed information about a single proxy. ```APIDOC ## stateOne ### Description Retrieves the selected proxy. ### Method `stateOne(tzid: number)` ### Parameters #### Path Parameters - **tzid** (number) - Required. The unique identifier (tzid) of the proxy to retrieve. ### Response #### Success Response (200) - **Get**: An object representing the selected proxy with detailed information. ### Request Example ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.proxy(); getter.stateOne(123).then((result) => { console.log(result); }); ``` ### Response Example ```json { "type": "private", "connect_type": "https", "host": "example.com", "port": 8080, "user": "user", "pass": "pass", "operator": "mts", "status": 1, "country": 7, "rent": "2023-01-01", "comment": "comment", "port_count": 1, "session": true, "city": "any", "traffic": "100MB", "general_traffic": "1GB", "stop_at": "2023-01-01", "check_at": "2023-01-01", "created_at": "2023-01-01", "updated_at": "2023-01-01", "tzid": 123, "time": 1234567890, "days": 1, "hours": 24, "change_ip": true, "change_type": true, "rotate": true } ``` ``` -------------------------------- ### Get OnlineProxy.io Tariffs and User Balance Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Fetches available proxy tariffs with pricing and periods, and retrieves the current user account balance. Requires an API key. ```typescript const driver = new OnlineSimDriver('your_apikey_here'); const { tariffs } = await driver.onlineProxy().getProxyTariffs(); tariffs.forEach(t => console.log(`${t.period}: $${t.price}`)); // 7d: $5.00 | 30d: $15.00 | 90d: $40.00 const { balance } = await driver.onlineProxy().getUserBalance(); console.log('Balance:', balance); // 42.50 ``` -------------------------------- ### Get Proxy Tariffs - TypeScript Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetOnlineProxy.md Retrieves available proxy periods and minimum order prices. Requires an API key, language code, and account ID for initialization. ```typescript const driver = new OnlineProxyAPI('APIKEY', 'en', 123); driver.getProxyTariffs().then((result) => { console.log(result); // Output: { tariffs: [{ period: '1 month', price: 10 }] } }); ``` -------------------------------- ### Manage Rental Operations Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetRent.md This snippet demonstrates various operations available through the rent getter, including fetching tariffs, getting general and specific states of rental operations, and closing a rental number using its tzid. ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.rent(); ggetter.tariffs().then((result) => { console.log(result); }); ggetter.get().then((result) => { console.log(result); }); ggetter.state().then((result) => { console.log(result); }); // or ggetter.stateOne(res.tzid).then((result) => { console.log(result); }); ggetter.close(res.tzid).then((result) => { console.log(result); }); ``` -------------------------------- ### Get Proxies Available for Order Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetOnlineProxy.md Fetches a list of proxies that are currently available for ordering, potentially based on filtering criteria. ```typescript const driver = new OnlineProxyAPI('APIKEY', 'en', 123); driver.getAvailableProxiesForOrder().then((result) => { console.log(result); // Output: { proxies: [{ id: 'proxy_id', ip: '127.0.0.1', port: 8080, type: 'HTTP', country: 'USA', city: 'New York', anonymity: 'High', speed: 100, uptime: 99, lastChecked: '2023-01-01', createdAt: '2023-01-01', updatedAt: '2023-01-01', comment: 'Proxy comment' }] } }); ``` -------------------------------- ### Browse Service Tariffs (All and Single Country) Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Retrieve pricing and availability information for services. `tariffs()` gets data for all countries, while `tariffsOne(country)` filters for a specific country. ```typescript const driver = new OnlineSimDriver('your_apikey_here'); // All countries const allTariffs = await driver.numbers().tariffs(); console.log(Object.keys(allTariffs)); // ['7', '1', '44', ...] // Single country (Russia = 7) const ruTariff = await driver.numbers().tariffsOne(7); console.log(ruTariff.name); // "Russia" console.log(ruTariff.services['vk']); // { count: 150, price: 0.5, popular: true, ... } ``` -------------------------------- ### Get Price for a Service Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetNumbers.md Retrieves the cost of a specific service in a given country. Ensure you have initialized the OnlineSimDriver with your API key. ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.numbers(); getter.price('service1', 7).then((result) => { console.log(result); // Output: "10" (assuming the price is 10) }); ``` -------------------------------- ### Get User Balance Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetUser.md Retrieves the user's current balance, Z-balance, and income. Ensure you have initialized the OnlineSimDriver with your API key. ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.user(); ggetter.balance().then((result) => { console.log(result); // Output: { balance: 100, zbalance: 50, income: 150 } }); ``` -------------------------------- ### Get User Balance - TypeScript Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetOnlineProxy.md Retrieves the current user balance. Requires an API key, language code, and account ID for initialization. ```typescript const driver = new OnlineProxyAPI('APIKEY', 'en', 123); driver.getUserBalance().then((result) => { console.log(result); // Output: { balance: 100 } }); ``` -------------------------------- ### Chain GetFree Methods: Countries, Numbers, Messages Source: https://github.com/s00d/onlinesim-js-api/wiki/GetFree Demonstrates chaining calls to get countries, then numbers for the first country, and finally messages for the first number. Requires an API key to be set in the driver. ```javascript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.free() getter.countries().then((result) => { getter.numbers(result[0].country).then((result) => { getter.messages(result[0].number).then((result) => { console.log(result); }) }) }) ``` -------------------------------- ### Get Service Price Source: https://github.com/s00d/onlinesim-js-api/wiki/GetNumbers Retrieves the price for a specific service in a given country. This helps in budgeting and understanding costs associated with using the service. ```javascript getter.price().then((result) => { console.log(result); }) ``` -------------------------------- ### Get User Profile Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetUser.md Fetches the user's profile details, including ID, name, email, and API key status. Requires the OnlineSimDriver to be initialized. ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.user(); ggetter.profile().then((result) => { console.log(result); // Output: { id: 1, name: 'John Doe', username: 'johndoe', email: 'john@example.com', apikey: 'apikey123', api_access: true, locale: 'en', number_region: 1, number_country: 7, number_reject: null, ugroup: 1, verify: 1, block: 0, payment: { payment: 100, income: 150, spent: 50, now: 200 } } }); ``` -------------------------------- ### Check Rental Status (Single and All) Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Retrieves the status of number rentals. `stateOne(tzid)` gets details for a single rental including messages, while `state()` returns an array of all active rentals. ```typescript const driver = new OnlineSimDriver('your_apikey_here'); const rental = await driver.rent().stateOne(789012); rental.messages.forEach(msg => { console.log(`[${msg.created_at}] from ${msg.service}: ${msg.text} (code: ${msg.code})`); }); const allRentals = await driver.rent().state(); console.log(`Active rentals: ${allRentals.length}`); ``` -------------------------------- ### Use Onlinesim JS API for Proxy Management Source: https://github.com/s00d/onlinesim-js-api/blob/master/README.md Initialize the driver with your API key and retrieve a list of proxies. Replace 'your_apikey_here' with your actual API key. ```javascript import OnlineSimDriver from "onlinesim-js-api"; const apikey = 'your_apikey_here'; const driver = new OnlineSimDriver(apikey); // Example usage for proxy management driver.onlineProxy().getProxyList().then((result) => { console.log(result); }); ``` -------------------------------- ### Initialize OnlineSimDriver Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Instantiate the main driver with your API key. Optional parameters include language and developer ID. Configuration can also be chained. ```typescript import OnlineSimDriver from 'onlinesim-js-api'; // Basic initialization const driver = new OnlineSimDriver('your_apikey_here'); // With optional language and dev_id const driver2 = new OnlineSimDriver('your_apikey_here', 'en', 42); // Chainable configuration const driver3 = new OnlineSimDriver() .setToken('your_apikey_here') .setLang('ru') .setBase('https://onlinesim.host/api/') .setOauth('oauth_token_here'); ``` -------------------------------- ### Initialize and Get SMS Number Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/index.md Initialize the OnlineSimDriver with your API key and retrieve a number for a specific service. Ensure you have your API key and the correct service name. ```javascript import OnlineSimDriver from "onlinesim-js-api"; const apikey = 'your_apikey_here'; const driver = new OnlineSimDriver(apikey); // Example usage driver.numbers().get('service_name').then((result) => { console.log(result); }); ``` -------------------------------- ### driver.numbers().tariffs() / driver.numbers().tariffsOne() Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Browses service tariffs. `tariffs()` returns pricing and availability for all countries, while `tariffsOne(country)` narrows the results to a specific country. ```APIDOC ## `driver.numbers().tariffs()` / `driver.numbers().tariffsOne()` — Browse Service Tariffs `tariffs()` returns pricing and availability for all countries; `tariffsOne(country)` narrows to one. ```typescript const driver = new OnlineSimDriver('your_apikey_here'); // All countries const allTariffs = await driver.numbers().tariffs(); console.log(Object.keys(allTariffs)); // ['7', '1', '44', ...] // Single country (Russia = 7) const ruTariff = await driver.numbers().tariffsOne(7); console.log(ruTariff.name); // "Russia" console.log(ruTariff.services['vk']); // { count: 150, price: 0.5, popular: true, ... } ``` ``` -------------------------------- ### driver.onlineProxy().getProxyTariffs() / driver.onlineProxy().getUserBalance() Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Fetches available tariffs and pricing periods from onlineproxy.io, and retrieves the current account balance. ```APIDOC ## `driver.onlineProxy().getProxyTariffs()` / `driver.onlineProxy().getUserBalance()` — Pricing & Balance Fetches available tariffs and pricing periods from onlineproxy.io, and retrieves the current account balance. ### Method GET ### Endpoint `/onlineProxy/getProxyTariffs` or `/onlineProxy/getUserBalance` ### Response #### Success Response (200) - **tariffs** (array) - List of available tariffs (for `getProxyTariffs`). - **period** (string) - The rental period for the tariff (e.g., '7d'). - **price** (number) - The price for the specified rental period. - **balance** (number) - The current user account balance (for `getUserBalance`). ``` -------------------------------- ### Get Number Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetNumbers.md Requests a phone number for a specific country code. ```APIDOC ## Get Number ### Description Requests a phone number for a specific country code. ### Method GET ### Endpoint /numbers/get ### Query Parameters - **country** (string) - Required - The country code for which to get a number. ### Response #### Success Response (200) - **tzid** (string) - The unique identifier for the requested number. ``` -------------------------------- ### Get Tariffs Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetNumbers.md Retrieves a list of available tariffs for phone numbers. ```APIDOC ## Get Tariffs ### Description Retrieves a list of available tariffs for phone numbers. ### Method GET ### Endpoint /numbers/tariffs ### Response #### Success Response (200) - **tariffs** (array) - A list of available tariffs. ``` -------------------------------- ### Get Selected Proxy Source: https://github.com/s00d/onlinesim-js-api/wiki/GetProxy Retrieves a specific proxy using its tzid. ```APIDOC ## stateOne ### Description Get selected proxy ### Method GET (implied by usage in example) ### Endpoint /getstate35 ### Parameters #### Query Parameters - **$tzid** (string) - Required - operation tzid ### Request Example ```js const driver = new OnlineSimDriver('APIKEY'); const getter = driver.proxy() // Assuming 'res' is the result from a previous 'get' call and contains 'tzid' getter.stateOne(res.tzid).then((result) => { console.log(result); }) ``` ### Response #### Success Response (200) - **result** (object) - Information about the selected proxy ``` -------------------------------- ### driver.proxy().get() Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Provisions a proxy from onlinesim.io with full control over class, type, protocol, operator, country, and city. ```APIDOC ## `driver.proxy().get()` — Acquire an OnlineSim Proxy Provisions a proxy from onlinesim.io with full control over class (days/traffic), type, protocol, operator, country, and city. ### Method POST ### Endpoint `/proxy/get` ### Parameters #### Request Body - **class** (string) - Required - 'days' or 'traffic'. - **type** (string) - Required - Proxy type (e.g., 'shared', 'private', 'multiport'). - **connect** (string) - Required - Connection protocol (e.g., 'https', 'socks'). - **count** (number) - Required - Number of proxies to acquire. - **operator** (string) - Optional - Mobile operator (e.g., 'mts', 'megafon'). - **country** (string) - Optional - Country code or 'any'. - **city** (string) - Optional - City name or 'any'. - **port_count** (number) - Optional - Number of ports for multiport proxies. - **session** (boolean) - Optional - Whether to enable session support. ### Response #### Success Response (200) - **connect_type** (string) - The connection type of the proxy. - **user** (string) - The username for proxy authentication. - **pass** (string) - The password for proxy authentication. - **host** (string) - The hostname of the proxy server. - **port** (number) - The port number of the proxy server. ``` -------------------------------- ### driver.numbers().getWithNumber() — Request a Number and Receive Its Digits Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Like `get()`, but also returns the phone number string and country code immediately — useful when you need to pass the number to a registration form before the SMS arrives. ```APIDOC ## `driver.numbers().getWithNumber()` — Request a Number and Receive Its Digits Like `get()`, but also returns the phone number string and country code immediately — useful when you need to pass the number to a registration form before the SMS arrives. ```typescript const driver = new OnlineSimDriver('your_apikey_here'); const { tzid, number, country } = await driver.numbers().getWithNumber('telegram', 7); console.log(`Number: +${number}, Country: ${country}, Operation: ${tzid}`); // Number: +79161234567, Country: 7, Operation: 654321 ``` ``` -------------------------------- ### free().countries(), free().numbers(), free().messages() Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Provides access to free, publicly-shared phone numbers for reading incoming SMS without authentication or cost. Includes methods to list countries, get available numbers, and read messages for a specific number. ```APIDOC ## `driver.free().countries()` / `driver.free().numbers()` / `driver.free().messages()` — Free Shared Numbers Provides access to free, publicly-shared phone numbers for reading incoming SMS without authentication or cost. ```typescript const driver = new OnlineSimDriver(); // no API key needed for free numbers // 1. List available countries const countries = await driver.free().countries(); console.log(countries[0]); // { country: 7, country_text: "Russia" } // 2. Get available free numbers for a country const numbers = await driver.free().numbers(7); console.log(numbers[0].full_number); // "+79161234567" // 3. Read messages for a specific number (phone as integer) const messages = await driver.free().messages(79161234567); messages.forEach(m => { console.log(`[${m.created_at}] From ${m.in_number}: ${m.text}`); }); ``` ``` -------------------------------- ### Get Number State Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetNumbers.md Retrieves the current state of all active phone numbers. ```APIDOC ## Get Number State ### Description Retrieves the current state of all active phone numbers. ### Method GET ### Endpoint /numbers/state ### Response #### Success Response (200) - **state** (object) - An object containing the state of each active number. ``` -------------------------------- ### Initialize and Use Onlinesim JS API Source: https://github.com/s00d/onlinesim-js-api/blob/master/README.md Initialize the driver with your API key and use it for SMS reception or proxy management. Ensure you replace 'your_apikey_here' with your actual API key. ```javascript import OnlineSimDriver from "onlinesim-js-api"; const apikey = 'your_apikey_here'; const driver = new OnlineSimDriver(apikey); // Example usage for SMS reception driver.numbers().get('service_name').then((result) => { console.log(result); }); // Example usage for proxy management driver.onlineProxy().getProxyList().then((result) => { console.log(result); }); ``` -------------------------------- ### Get Proxy by ID Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetOnlineProxy.md Retrieves the proxy details for a specific proxy ID. ```APIDOC ## getProxy ### Description Retrieves the proxy with the specified ID. ### Method Signature `(id: string) => Promise` ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the proxy. ### Request Example ```typescript const driver = new OnlineProxyAPI('APIKEY', 'en', 123); driver.getProxy('proxy_id').then((result) => { console.log(result); // Output: { id: 'proxy_id', ip: '127.0.0.1', port: 8080, type: 'HTTP', country: 'USA', city: 'New York', anonymity: 'High', speed: 100, uptime: 99, lastChecked: '2023-01-01', createdAt: '2023-01-01', updatedAt: '2023-01-01', comment: 'Proxy comment' } }); ``` ### Response #### Success Response (Proxy Object) - **id** (string) - The unique identifier of the proxy. - **ip** (string) - The IP address of the proxy. - **port** (number) - The port number for the proxy. - **type** (string) - The type of proxy (e.g., HTTP, SOCKS). - **country** (string) - The country where the proxy is located. - **city** (string) - The city where the proxy is located. - **anonymity** (string) - The level of anonymity provided by the proxy. - **speed** (number) - The speed of the proxy connection. - **uptime** (number) - The uptime percentage of the proxy. - **lastChecked** (string) - The date and time the proxy was last checked. - **createdAt** (string) - The date and time the proxy was created. - **updatedAt** (string) - The date and time the proxy was last updated. - **comment** (string) - Any associated comment for the proxy. ``` -------------------------------- ### driver.onlineProxy().orderProxy() Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Places a new proxy order using a data object matching the available filters. ```APIDOC ## `driver.onlineProxy().orderProxy()` — Order a New Proxy from OnlineProxy.io Places a new proxy order using a data object matching the available filters. ### Method POST ### Endpoint `/onlineProxy/orderProxy` ### Parameters #### Request Body - **country** (string) - Required - The desired country code for the proxy (e.g., 'US'). - **period** (string) - Required - The rental period for the proxy (e.g., '30d'). - **protocol** (string) - Required - The desired protocol for the proxy (e.g., 'https'). - **quantity** (number) - Required - The number of proxies to order. ### Response #### Success Response (200) - **orderId** (string) - The ID of the placed order. - **success** (boolean) - Indicates if the order was placed successfully. ``` -------------------------------- ### driver.numbers().service() / driver.numbers().serviceNumber() Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Lists available services. `service()` returns a list of all supported service slugs, and `serviceNumber(service)` returns available phone numbers for a specific service. ```APIDOC ## `driver.numbers().service()` / `driver.numbers().serviceNumber()` — List Available Services `service()` returns a list of all supported service slugs; `serviceNumber(service)` returns available phone numbers for a specific service. ```typescript const driver = new OnlineSimDriver('your_apikey_here'); const services = await driver.numbers().service(); console.log(services); // ['google', 'telegram', 'whatsapp', 'vk', ...] const numbers = await driver.numbers().serviceNumber('telegram'); console.log(numbers); // ['+79161234567', '+79031112233', ...] ``` ``` -------------------------------- ### driver.proxy().state() / driver.proxy().stateOne() Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Returns current proxy state(s), including connection details, rotation settings, and expiry. ```APIDOC ## `driver.proxy().state()` / `driver.proxy().stateOne()` — Check OnlineSim Proxy Status Returns current proxy state(s), including connection details, rotation settings, and expiry. ### Method GET ### Endpoint `/proxy/state` or `/proxy/stateOne/{tzid}` ### Parameters #### Query Parameters (for `state`) - **order** (string) - Optional - Sorting order for proxies (e.g., 'ASC'). #### Path Parameters (for `stateOne`) - **tzid** (number) - Required - The unique identifier of the proxy. ### Response #### Success Response (200) - **tzid** (number) - The unique identifier of the proxy. - **host** (string) - The hostname of the proxy server. - **port** (number) - The port number of the proxy server. - **rotate** (boolean) - Indicates if IP rotation is enabled. - **stop_at** (string) - The expiry date/time of the proxy. ``` -------------------------------- ### Get Next Message Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetNumbers.md Retrieves the next incoming message for a specific phone number. ```APIDOC ## Get Next Message ### Description Retrieves the next incoming message for a specific phone number. ### Method GET ### Endpoint /numbers/next ### Query Parameters - **tzid** (string) - Required - The unique identifier of the number. ### Response #### Success Response (200) - **message** (string) - The content of the next message. ``` -------------------------------- ### user().profile() Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Fetches the full user profile details, including username, email, API access status, and payment information. ```APIDOC ## `driver.user().profile()` — Get Account Profile Returns full user profile details including email, API key, locale, verification status, and payment summary. ```typescript const driver = new OnlineSimDriver('your_apikey_here'); const profile = await driver.user().profile(); console.log(profile.username); // "john_doe" console.log(profile.email); // "john@example.com" console.log(profile.api_access); // true console.log(profile.payment.now); // 12.50 (current balance) console.log(profile.locale); // "en" ``` ``` -------------------------------- ### Get Single Number State Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetNumbers.md Retrieves the current state of a specific phone number. ```APIDOC ## Get Single Number State ### Description Retrieves the current state of a specific phone number. ### Method GET ### Endpoint /numbers/stateOne ### Query Parameters - **tzid** (string) - Required - The unique identifier of the number. ### Response #### Success Response (200) - **state** (object) - An object containing the state of the specified number. ``` -------------------------------- ### Chained API Calls for Free Resources Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetFree.md Demonstrates chaining calls to retrieve countries, then phone numbers from the first country, and finally messages for the first number. This showcases a common workflow for obtaining and processing free resources. ```typescript const driver = new OnlineSimDriver('APIKEY'); const getter = driver.free(); getter.countries().then((countries) => { getter.numbers(countries[0].country).then((numbers) => { getter.messages(numbers[0].number).then((messages) => { console.log(messages); }); }); }); ``` -------------------------------- ### OnlineSimDriver - Main Driver / Constructor Source: https://context7.com/s00d/onlinesim-js-api/llms.txt The root entry point for all API interactions. Accepts an API token, optional language, and optional developer ID. Provides chainable setter methods to configure OAuth, token, language, and base URL at runtime. ```APIDOC ## `OnlineSimDriver` — Main Driver / Constructor The root entry point for all API interactions. Accepts an API token, optional language, and optional developer ID. Provides chainable setter methods to configure OAuth, token, language, and base URL at runtime. ```typescript import OnlineSimDriver from 'onlinesim-js-api'; // Basic initialization const driver = new OnlineSimDriver('your_apikey_here'); // With optional language and dev_id const driver2 = new OnlineSimDriver('your_apikey_here', 'en', 42); // Chainable configuration const driver3 = new OnlineSimDriver() .setToken('your_apikey_here') .setLang('ru') .setBase('https://onlinesim.host/api/') .setOauth('oauth_token_here'); ``` ``` -------------------------------- ### Get Messages Source: https://github.com/s00d/onlinesim-js-api/blob/master/docs/api/GetFree.md Retrieves the list of messages for a specified phone number, with optional pagination. ```APIDOC ## `messages` ### Description Retrieves the list of messages for a specific phone number. ### Method Signature `(phone: number, page?: number) => Promise>` ### Parameters #### Query Parameters - **phone** (number) - Required - The phone number for which to retrieve messages. - **page** (number) - Optional - The page number for pagination. Defaults to 1. ### Response Example ```json [ { "text": "Hello", "in_number": "1234567890", "my_number": 1, "created_at": "2023-01-01", "data_humans": "1 day ago" } ] ``` ``` -------------------------------- ### driver.rent().close() / driver.rent().portReload() Source: https://context7.com/s00d/onlinesim-js-api/llms.txt Manages the rental lifecycle. `close(tzid)` terminates the rental early, and `portReload(tzid)` reloads the port for the rented number. ```APIDOC ## `driver.rent().close()` / `driver.rent().portReload()` — Manage Rental Lifecycle `close(tzid)` terminates the rental early; `portReload(tzid)` reloads the port for the rented number. ```typescript const driver = new OnlineSimDriver('your_apikey_here'); await driver.rent().portReload(789012); // reload port await driver.rent().close(789012); // terminate rental console.log('Rental closed'); ``` ```