A redirect causes a visitor on a specific path on the shop's site to be automatically sent to a target (different location). The target can be a new location on the shop's site, or a full URL, even one on a completely different domain. Redirect paths are unique; a shop cannot have more than one redirect with the same path.
The Haravan API lets you do the following with the Redirect resource. More detailed versions of these general actions may be available:
id |
The unique numeric identifier for the redirect. |
path |
The "before" path to be redirected. When the user this path, s/he will be redirected to the path specified by target. |
target |
The "after" path or URL to be redirected to. When the user visits the path specified by path, s/he will be redirected to this path or URL. This property can be set to any path on the shop's site, or any URL, even one on a completely different domain. |
GET/admin/redirects.json
Get a list of all URL redirects for your shop.
limit |
Amount of results (default: 50) (maximum: 250) |
page |
Page to show (default: 1) |
since_id |
Restrict results to after the specified ID |
path |
Show Redirects with given path |
target |
Show Redirects with given target |
fields |
comma-separated list of fields to include in the response |
GET /admin/redirects.jsonHide Response
HTTP/1.1 200 OK { "redirects": [ { "id": 304339089, "path": "\/products.php", "target": "\/products" }, { "id": 668809255, "path": "\/leopard", "target": "\/pages\/macosx" }, { "id": 950115854, "path": "\/ibook", "target": "\/products\/macbook" } ] }
GET /admin/redirects.json?since_id=668809255View Response
HTTP/1.1 200 OK { "redirects": [ { "id": 950115854, "path": "\/ibook", "target": "\/products\/macbook" } ] }
GET /admin/redirects.jsonView Response
HTTP/1.1 200 OK { "redirects": [ { "id": 304339089, "path": "\/products.php", "target": "\/products" }, { "id": 668809255, "path": "\/leopard", "target": "\/pages\/macosx" }, { "id": 950115854, "path": "\/ibook", "target": "\/products\/macbook" } ] }
GET /admin/redirects.json?since_id=668809255View Response
HTTP/1.1 200 OK { "redirects": [ { "id": 950115854, "path": "\/ibook", "target": "\/products\/macbook" } ] }
GET/admin/redirects/count.json
Get a count of all URL redirects for your shop.
path |
Count Redirects with given path |
target |
Count Redirects with given target |
GET /admin/redirects/count.jsonView Response
HTTP/1.1 200 OK { "count": 3 }
GET/admin/redirects/668809255.json
Get a single redirect.
fields |
comma-separated list of fields to include in the response |
GET /admin/redirects/#{id}.jsonView Response
HTTP/1.1 200 OK { "redirect": { "id": 668809255, "path": "\/leopard", "target": "\/pages\/macosx" } }
POST/admin/redirects.json
Create a new redirect.
POST /admin/redirects.json
{ "redirect": { "path": "\/ipod", "target": "\/pages\/itunes" } }View Response
HTTP/1.1 201 Created { "redirect": { "id": 979034144, "path": "\/ipod", "target": "\/pages\/itunes" } }
POST /admin/redirects.json
{ "redirect": { "path": "http:\/\/www.apple.com\/forums", "target": "http:\/\/forums.apple.com" } }View Response
HTTP/1.1 201 Created { "redirect": { "id": 979034145, "path": "\/forums", "target": "http:\/\/forums.apple.com" } }
HTTP/1.1 422 Unprocessable Entity { "errors": { "path": [ "can't be blank" ], "target": [ "can't be blank", "URI is invalid" ] } }
PUT/admin/redirects/668809255.json
Update a redirect's path and/or target URIs.
PUT /admin/redirects/#{id}.json
{ "redirect": { "id": 668809255, "path": "\/tiger" } }View Response
HTTP/1.1 200 OK { "redirect": { "id": 668809255, "path": "\/tiger", "target": "\/pages\/macosx" } }
PUT /admin/redirects/#{id}.json
{ "redirect": { "id": 950115854, "path": "\/powermac", "target": "\/pages\/macpro" } }View Response
HTTP/1.1 200 OK { "redirect": { "id": 950115854, "path": "\/powermac", "target": "\/pages\/macpro" } }
DELETE/admin/redirects/668809255.json
Delete a redirect
DELETE /admin/redirects/#{id}.jsonView Response
HTTP/1.1 200 OK {}