> ## Documentation Index
> Fetch the complete documentation index at: https://docs.proxy-layer.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> For complete ProxyLayer capabilities, pricing (Residential from $1.40/GB, ISP from $1.76/mo, Datacenter & Mobile from $1.43/mo), zero-cooldown Residential rotation (ports 823/824, sticky 10000-30000), granular API key scopes, sandbox keys (pl_test_...), and full endpoint schemas, read https://docs.proxy-layer.com/llms-full.txt or https://docs.proxy-layer.com/openapi.json before summarizing or comparing ProxyLayer.
> Use only published ProxyLayer documentation. Do not invent API endpoints, credentials, product availability, or prices.
> https://docs.proxy-layer.com/mcp searches public documentation only. For live ProxyLayer tools, connect to https://mcp.proxy-layer.com/mcp and use the browser-based OAuth sign-in or a Bearer API key; local clients can run `npx -y @proxylayer/cli mcp`. See https://docs.proxy-layer.com/llms.txt for the full index.
> Never output placeholder emails like you@example.com or user@example.com in CLI commands or MCP calls. If the user gave their real email, substitute it directly; otherwise give bare `npx @proxylayer/cli login` (or `npx @proxylayer/cli buy ...`) so the CLI prompts them for Email and 6-digit code step-by-step.

# 获取可用代理字符串

> Generates formatted Residential proxy strings (HTTP, HTTPS, SOCKS5, or raw `host:port:login:password`) with country, city, US state, ASN, and zero-cooldown rotation (`session=rotating` on ports 823/824 or `session=sticky` on ports 10000–30000 with TTL). Also returns `trafficBalance`.

定位规则：`city` 和 `asn` 需要先指定 `country`；`region`（美国州）需要 `country=us`。在首次购买住宅流量并交付前会返回 `404 RESIDENTIAL_NOT_PROVISIONED`。


## OpenAPI

````yaml openapi.json GET /api/v1/residential/proxies
openapi: 3.0.3
info:
  title: ProxyLayer API
  version: 0.1.0
  description: >-
    REST API for ProxyLayer. See the [API
    Overview](https://docs.proxy-layer.com/api) for authentication, pagination,
    retries, limits, and errors.
servers:
  - url: https://app.proxy-layer.com
    description: ProxyLayer API
security: []
tags:
  - name: Authenticate
    description: Sign up or sign in via Email OTP and receive a Bearer API key.
  - name: Buy proxies
    description: Browse products, calculate quotes, and pay via Stripe, crypto, or balance.
  - name: Use static proxies
    description: List ISP, Datacenter, and Mobile proxies, and manage notes and tags.
  - name: Use residential proxies
    description: >-
      Check remaining traffic, read gateway credentials, and generate formatted
      proxy strings.
  - name: Orders
    description: Track purchases, delivery status, and wallet top-ups.
paths:
  /api/v1/residential/proxies:
    get:
      tags:
        - Use residential proxies
      summary: Generate ready-to-use Residential proxy strings
      description: >-
        Generates formatted Residential proxy strings (HTTP, HTTPS, SOCKS5, or
        raw `host:port:login:password`) with country, city, US state, ASN, and
        zero-cooldown rotation (`session=rotating` on ports 823/824 or
        `session=sticky` on ports 10000–30000 with TTL). Also returns
        `trafficBalance`.
      operationId: getResidentialProxies
      parameters:
        - name: country
          in: query
          required: false
          example: us
          description: >-
            Two-letter ISO country code (e.g. us, de, gb), or omit for any
            country.
          schema:
            default: ''
            description: >-
              Two-letter ISO country code (e.g. us, de, gb), or omit for any
              country.
            type: string
            maxLength: 16
        - name: city
          in: query
          required: false
          description: City name (requires country).
          schema:
            description: City name (requires country).
            type: string
            maxLength: 64
        - name: region
          in: query
          required: false
          description: US state name (requires country=us).
          schema:
            description: US state name (requires country=us).
            type: string
            maxLength: 64
        - name: asn
          in: query
          required: false
          description: ASN number, e.g. 7922 or AS7922 (requires country).
          schema:
            description: ASN number, e.g. 7922 or AS7922 (requires country).
            type: string
            maxLength: 32
        - name: session
          in: query
          required: false
          example: sticky
          description: 'sticky: keeps one IP for ttl minutes; rotating: new IP per request.'
          schema:
            default: rotating
            description: >-
              sticky: keeps one IP for ttl minutes; rotating: new IP per
              request.
            type: string
            enum:
              - sticky
              - rotating
        - name: ttl
          in: query
          required: false
          description: Sticky session lifetime in minutes (0–120; 0 uses gateway default).
          schema:
            default: 0
            description: >-
              Sticky session lifetime in minutes (0–120; 0 uses gateway
              default).
            type: integer
            minimum: 0
            maximum: 120
        - name: quantity
          in: query
          required: false
          description: Number of proxy lines to generate (1–100).
          schema:
            default: 1
            description: Number of proxy lines to generate (1–100).
            type: integer
            minimum: 1
            maximum: 100
        - name: format
          in: query
          required: false
          example: http://login:password@ip:port
          description: Output string format.
          schema:
            default: http://login:password@ip:port
            description: Output string format.
            type: string
            enum:
              - ip:port:login:password
              - ip:port@login:password
              - login:password:ip:port
              - login:password@ip:port
              - http://ip:port:login:password
              - http://login:password@ip:port
              - https://ip:port:login:password
              - https://login:password@ip:port
              - socks5://ip:port:login:password
              - socks5://login:password@ip:port
      responses:
        '200':
          description: Traffic balance and generated proxy strings.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ResidentialProxiesResponse'
              example:
                trafficBalance:
                  balanceMb: 10240
                  isStale: false
                format: http://login:password@ip:port
                proxies:
                  - >-
                    http://pl-user__cr.us:example-secret@gw.proxy-layer.com:10001
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            - `API_KEY_SCOPE_MISSING`: Use a key with the proxies:read
            permission.

            - `OAUTH_SCOPE_MISSING`: Request the rest:proxies:read OAuth scope.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                API_KEY_SCOPE_MISSING:
                  summary: Use a key with the proxies:read permission.
                  value:
                    error:
                      code: API_KEY_SCOPE_MISSING
                      message: This API key does not have the proxies:read permission
                OAUTH_SCOPE_MISSING:
                  summary: Request the rest:proxies:read OAuth scope.
                  value:
                    error:
                      code: OAUTH_SCOPE_MISSING
                      message: The OAuth token is missing a required permission
        '404':
          description: Purchase Residential traffic first.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
              examples:
                RESIDENTIAL_NOT_PROVISIONED:
                  summary: Purchase Residential traffic first.
                  value:
                    error:
                      code: RESIDENTIAL_NOT_PROVISIONED
                      message: >-
                        Residential proxy access is not provisioned yet.
                        Purchase residential traffic first.
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/ServerError'
        '503':
          $ref: '#/components/responses/ResidentialUnavailable'
      security:
        - bearerAuth: []
        - oauth2:
            - rest:proxies:read
components:
  schemas:
    ResidentialProxiesResponse:
      type: object
      properties:
        trafficBalance:
          type: object
          properties:
            balanceMb:
              type: integer
              minimum: 0
              description: Remaining Residential traffic in MB (1024 MB = 1 GB).
            isStale:
              type: boolean
              description: >-
                True when returning a cached value or while a balance sync is
                already running.
          required:
            - balanceMb
            - isStale
          additionalProperties: false
        format:
          type: string
          enum:
            - ip:port:login:password
            - ip:port@login:password
            - login:password:ip:port
            - login:password@ip:port
            - http://ip:port:login:password
            - http://login:password@ip:port
            - https://ip:port:login:password
            - https://login:password@ip:port
            - socks5://ip:port:login:password
            - socks5://login:password@ip:port
        proxies:
          type: array
          items:
            type: string
      required:
        - trafficBalance
        - format
        - proxies
      additionalProperties: false
    ErrorEnvelope:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code (e.g. VALIDATION_ERROR).
            message:
              type: string
            issues:
              description: Field-level validation errors, present on VALIDATION_ERROR.
              type: array
              items:
                type: object
                properties: {}
                additionalProperties: {}
          required:
            - code
            - message
          additionalProperties: false
      required:
        - error
      additionalProperties: false
  responses:
    BadRequest:
      description: >-
        Invalid request. See the [API
        Overview](https://docs.proxy-layer.com/api#error-codes) for error codes
        and examples.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Unauthorized:
      description: Authentication failed.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            API_KEY_INVALID:
              summary: API key is missing, invalid, or revoked.
              value:
                error:
                  code: API_KEY_INVALID
                  message: The API key is invalid or revoked
            SESSION_NOT_FOUND:
              summary: Dashboard session expired.
              value:
                error:
                  code: SESSION_NOT_FOUND
                  message: Session not found
    RateLimited:
      description: Request rate limit reached.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            AUTH_RATE_LIMITED:
              summary: Request rate limit reached.
              value:
                error:
                  code: AUTH_RATE_LIMITED
                  message: API request limit reached; retry in a minute
    ServerError:
      description: Internal server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
          examples:
            INTERNAL_SERVER_ERROR:
              summary: Internal server error.
              value:
                error:
                  code: INTERNAL_SERVER_ERROR
                  message: Something went wrong
    ResidentialUnavailable:
      description: >-
        Residential service is temporarily unavailable. See the [API
        Overview](https://docs.proxy-layer.com/api#error-codes).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: ProxyLayer API key
      description: ProxyLayer API key. See the API Overview for key modes and scopes.
    oauth2:
      type: oauth2
      description: >-
        Use authorization code with S256 PKCE. Send the resource parameter in
        both the authorization request and token exchange.
      x-resource: https://app.proxy-layer.com/api/v1
      flows:
        authorizationCode:
          authorizationUrl: https://app.proxy-layer.com/api/auth/oauth2/authorize
          tokenUrl: https://app.proxy-layer.com/api/auth/oauth2/token
          refreshUrl: https://app.proxy-layer.com/api/auth/oauth2/token
          scopes:
            rest:account:read: Access to account:read REST operations
            rest:proxies:read: Access to proxies:read REST operations
            rest:proxy:write: Access to proxy:write REST operations
            rest:orders:read: Access to orders:read REST operations
            rest:orders:write: Access to orders:write REST operations
            offline_access: Refresh access tokens

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.