Snipget.ai

Urls query edit

Exact
urls_query_edit

Deterministic and authoritative — the canonical answer for this input.

Edit a URL's query string: get the value(s) for a key, set (replace) a key, add (append) another value, or remove a key. Returns the modified URL and the resulting query as a dict. The input must be a valid absolute URL: a missing scheme or a malformed host is rejected as is_valid:false, same as urls_normalize. Processing multiple inputs? Use `urls_query_edit_batch` to do up to 1000 in one call.

Parameters

valuestringrequired

The URL whose query to edit.

operationstringrequired

get, set, add, or remove.

keystringrequired

The query parameter name.

query_valuestringoptional

The value for set/add.

Call it

curl -X POST https://api.snipget.ai/v1/urls/query-edit \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"value":"https://example.com/search?q=shoes&page=2","operation":"set","key":"page","query_value":"3"}'

The Batch tab sends up to 1000 inputs in one call via /v1/urls/query-edit/batch.

Example response

{
  "input": "https://example.com/search?q=shoes&page=2",
  "is_valid": true,
  "operation": "set",
  "url": "https://example.com/search?q=shoes&page=3",
  "query": {
    "q": [
      "shoes"
    ],
    "page": [
      "3"
    ]
  }
}

FAQ

What can I do with it?

Change the ?key=value part of a link safely with one of four operations: get (read a value), set (replace it), add (append another value for the same key), or remove (delete it). It re-encodes the URL correctly for you, so you avoid the escaping bugs that come from editing the string by hand.

What's the difference between set and add?

set replaces the key with a single value, so any existing copies are removed first. add appends another value and keeps the existing ones, which is how you build a repeated key like ?tag=a&tag=b.

Why does the returned query show values as lists?

Because a key can appear more than once in a URL, each key maps to a list of its values so nothing is lost. With get, the value field returns every value found for the key you asked about.

Which fields are required?

value (the URL), operation, and key are always required; query_value is only needed for set and add. An unknown operation or a missing key is rejected with an INVALID_INPUT error and not billed.

Is the edit exact?

Yes. It is deterministic: the same URL and operation always produce the same result, with standards-correct encoding, so no guessing is involved.

Related tools