Metadata
Using and working with metadata in the Ping Proxies API
Metadata provides a flexible way to store additional information with your resources. The Ping Proxies API supports metadata on several resources, allowing you to add custom attributes without changing the core API structure.
Metadata is particularly useful for resellers who want to store information about their customers on our systems, or users who want to label or add information to specific proxy users or services.
Supported Resources with Metadata
The following resources support metadata fields:
- Proxy Users (
proxy_user_metadata
) - Services (
service_metadata
)
Metadata Structure
Metadata is stored as a JSON object with key-value pairs. For example:
Supported Value Types
Metadata supports the following value types:
- String: Text values (e.g.,
"department": "Marketing"
) - Integer: Whole numbers (e.g.,
"employee_id": 1500
) - Float: Decimal numbers (e.g.,
"success_rate": 98.6
) - Boolean: True/false values (e.g.,
"is_priority": true
)
To store datetime objects, we recommend using timestamps as integers since they’re more efficiently stored and queried. They can also be compared using the min_ and max_ operators.
Constraints
When working with metadata in the Ping Proxies API, keep these constraints in mind:
- Non-nested structure: Metadata must be a flat JSON object (no nested objects)
- Limited keys: Maximum of 30 keys per metadata object
- Value length: Each value’s string representation must be ≤ 300 characters
- Size limit: Total metadata size must be ≤ 32KB
- Supported value types: String, boolean, float, and integer values
Adding Metadata
You can add metadata when creating or updating resources. For example, when creating a proxy user:
Updating Metadata
When updating metadata, you must provide the complete metadata object. The API will replace the existing metadata with your new object, not merge them.
For example, to update a service’s metadata:
Searching by Metadata
The API allows filtering resources based on their metadata values. This is particularly powerful for organizing and retrieving resources based on your custom attributes.
Metadata Search Operators
When searching, you can use the following formats:
- Exact match:
proxy_user_metadata.department=Marketing
- Minimum value:
proxy_user_metadata.min_employee_id=1000
- Maximum value:
proxy_user_metadata.max_employee_id=2000
- Contains substring:
proxy_user_metadata.like_project=%Campaign%
- Not equal:
proxy_user_metadata.not_department=IT
- Existence check:
proxy_user_metadata.exists_project=true
(key must exist)proxy_user_metadata.exists_project=false
(key must not exist)
Code Examples
Example Use Cases
- Reseller customer tracking: Store client-specific identifiers and attributes
- Client organization: Track which client or project a resource belongs to
- Custom grouping: Create your own grouping scheme beyond the API’s built-in categories
- Usage tracking: Add purpose or usage details to track resource utilization
By effectively using metadata, you can extend the Ping Proxies API to fit your organization’s specific needs and workflows.