|
| 1 | +--- |
| 2 | +title: "Mobile Proxies" |
| 3 | +--- |
| 4 | + |
| 5 | +Mobile proxies route traffic through mobile carrier networks. Only recommended in advanced stealth use cases. |
| 6 | + |
| 7 | +<Info> |
| 8 | +Mobile carrier IPs often route through shared regional gateways. Country targeting is the most reliable option; city and US state targeting are best-effort and may not match every third-party geolocation database. |
| 9 | +</Info> |
| 10 | + |
| 11 | +## Configuration |
| 12 | + |
| 13 | +Create a mobile proxy with a target country: |
| 14 | + |
| 15 | +<CodeGroup> |
| 16 | +```typescript Typescript/Javascript |
| 17 | +import Kernel from '@onkernel/sdk'; |
| 18 | + |
| 19 | +const kernel = new Kernel(); |
| 20 | + |
| 21 | +const proxy = await kernel.proxies.create({ |
| 22 | + type: 'mobile', |
| 23 | + name: 'my-us-mobile', |
| 24 | + config: { |
| 25 | + country: 'US' |
| 26 | + } |
| 27 | +}); |
| 28 | + |
| 29 | +const browser = await kernel.browsers.create({ |
| 30 | + proxy_id: proxy.id, |
| 31 | +}); |
| 32 | +``` |
| 33 | + |
| 34 | +```python Python |
| 35 | +from kernel import Kernel |
| 36 | + |
| 37 | +kernel = Kernel() |
| 38 | + |
| 39 | +proxy = kernel.proxies.create( |
| 40 | + type='mobile', |
| 41 | + name='my-us-mobile', |
| 42 | + config={ |
| 43 | + 'country': 'US' |
| 44 | + } |
| 45 | +) |
| 46 | + |
| 47 | +browser = kernel.browsers.create(proxy_id=proxy.id) |
| 48 | +``` |
| 49 | +</CodeGroup> |
| 50 | + |
| 51 | +## Configuration parameters |
| 52 | + |
| 53 | +- **`country`** - ISO 3166 country code. Must be provided when providing other targeting options. |
| 54 | +- **`state`** - US-only two-letter state code. Best-effort for mobile proxies. |
| 55 | +- **`city`** - Provider city alias, such as `brooklyn` or `chicago`. Best-effort for mobile proxies. |
| 56 | +- **`bypass_hosts`** (optional) - Array of hostnames that bypass the proxy and connect directly (max 100 entries) |
| 57 | + |
| 58 | +## Advanced targeting examples |
| 59 | + |
| 60 | +### Target by city |
| 61 | + |
| 62 | +Route traffic through a specific city: |
| 63 | + |
| 64 | +<CodeGroup> |
| 65 | + |
| 66 | +```typescript Typescript/Javascript |
| 67 | +const proxy = await kernel.proxies.create({ |
| 68 | + type: 'mobile', |
| 69 | + name: 'brooklyn-mobile', |
| 70 | + config: { |
| 71 | + country: 'US', |
| 72 | + state: 'NY', |
| 73 | + city: 'brooklyn' |
| 74 | + } |
| 75 | +}); |
| 76 | +``` |
| 77 | + |
| 78 | +```Python Python |
| 79 | +proxy = kernel.proxies.create( |
| 80 | + type='mobile', |
| 81 | + name='brooklyn-mobile', |
| 82 | + config={ |
| 83 | + 'country': 'US', |
| 84 | + 'state': 'NY', |
| 85 | + 'city': 'brooklyn' |
| 86 | + } |
| 87 | +) |
| 88 | +``` |
| 89 | + |
| 90 | +</CodeGroup> |
| 91 | + |
| 92 | +<Note> |
| 93 | +If the city alias is not matched, the API returns examples from the target state to help you find the correct value. |
| 94 | +</Note> |
| 95 | + |
| 96 | +### Target by state |
| 97 | + |
| 98 | +Route traffic through a US state: |
| 99 | + |
| 100 | +<CodeGroup> |
| 101 | + |
| 102 | +```typescript Typescript/Javascript |
| 103 | +const proxy = await kernel.proxies.create({ |
| 104 | + type: 'mobile', |
| 105 | + name: 'ny-mobile', |
| 106 | + config: { |
| 107 | + country: 'US', |
| 108 | + state: 'NY' |
| 109 | + } |
| 110 | +}); |
| 111 | +``` |
| 112 | + |
| 113 | +```Python Python |
| 114 | +proxy = kernel.proxies.create( |
| 115 | + type='mobile', |
| 116 | + name='ny-mobile', |
| 117 | + config={ |
| 118 | + 'country': 'US', |
| 119 | + 'state': 'NY' |
| 120 | + } |
| 121 | +) |
| 122 | +``` |
| 123 | + |
| 124 | +</CodeGroup> |
| 125 | + |
| 126 | +## Bypass hosts |
| 127 | + |
| 128 | +Configure specific hostnames to bypass the proxy: |
| 129 | + |
| 130 | +<CodeGroup> |
| 131 | +```typescript Typescript/Javascript |
| 132 | +const proxy = await kernel.proxies.create({ |
| 133 | + type: 'mobile', |
| 134 | + name: 'mobile-with-bypass', |
| 135 | + config: { |
| 136 | + country: 'US', |
| 137 | + }, |
| 138 | + bypass_hosts: [ |
| 139 | + 'localhost', |
| 140 | + 'metadata.google.internal', |
| 141 | + '*.internal.company.com', |
| 142 | + ], |
| 143 | +}); |
| 144 | +``` |
| 145 | + |
| 146 | +```python Python |
| 147 | +proxy = kernel.proxies.create( |
| 148 | + type='mobile', |
| 149 | + name='mobile-with-bypass', |
| 150 | + config={ |
| 151 | + 'country': 'US', |
| 152 | + }, |
| 153 | + bypass_hosts=[ |
| 154 | + 'localhost', |
| 155 | + 'metadata.google.internal', |
| 156 | + '*.internal.company.com', |
| 157 | + ] |
| 158 | +) |
| 159 | +``` |
| 160 | +</CodeGroup> |
| 161 | + |
| 162 | +See the [overview](/proxies/overview#bypass-hosts) for full bypass host rules and examples. |
0 commit comments