ScriptTag
Version: 1.0
The ScriptTag resource represents remote javascript which is loaded into the pages of a shop's storefront and in the final "Thank You" page of checkout. This makes it easy to add functionality to those pages without touching any theme templates. A script tag has two main attributes:
- src: The URL of the remote script.
- event: The DOM event which triggers the loading of the script. Currently, "onload" is the only supported event.
When an app is uninstalled from a shop, all of the script tags which it created are automatically removed along with it.
Reminder A ScriptTag will only appear in checkout if the src starts with 'https://' in order not to break the SSL lock.
Authenticated access scopes: web.read_script_tags
, com.write_script_tags
What you can do with ScriptTag
The Haravan API lets you do the following with the ScriptTag resource.
- GET
https://apis.haravan.com/web/script_tags.json
- GET
https://apis.haravan.com/web/script_tags/count.json
- GET
https://apis.haravan.com/web/script_tags/{script_tags_id}.json
- POST
https://apis.haravan.com/web/script_tags.json
- PUT
https://apis.haravan.com/web/script_tags/{script_tags_id}.json
- DELETE
https://apis.haravan.com/web/script_tags/{script_tags_id}.json
ScriptTag properties
created_at
:string
{"created_at": "2021-05-13T07:29:20.1Z"}
The date and time (ISO 8601 format) when the ScriptTag was created.
event
:string
{"event": "onload"}
DOM event which triggers the loading of the script. Valid values are: "onload".
id
:number
{"id": 1206854680}
The unique numeric identifier for the ScriptTag.
src
:string
{"src": "http://yourapp.com/foo.js"}
Specifies the location of the ScriptTag.
updated_at
:string
{"updated_at": "2021-05-13T07:29:20.808Z"}
The date and time (ISO 8601 format) when the ScriptTag was last updated.
display_scope
:string
{"display_scope": "all"}
Specifies where the file should be included. Valid values are: "all".
Endpoints
Receive a list of all ScriptTags.
Parameters
limit
(default: 50) (maximum: 50)
Limit of the result.
page
(default: 1)
Page to show the result.
since_id
Restrict results to after the specified ID
created_at_min
Show script_tags created after date (format: 2008-12-31 03:00).
created_at_max
Show script_tags created before date (format: 2008-12-31 03:00).
updated_at_min
Show script_tags created after date (format: 2008-12-31 03:00).
updated_at_max
Show script_tags updated after date (format: 2008-12-31 03:00).
fields
Comma-separated list of fields to include in the response.
src
Show script tags with a given URL.
Retrieves a list of enabling script_tag by page number. By default, the number of resources on the page is 50.
GET https://apis.haravan.com/web/script_tags.json?page=2
Details
HTTP/1.1 200 OK
{
"script_tags": [
{
"created_at": "2022-02-09T03:13:35.224Z",
"event": "onload",
"id": 1000132951,
"src": "https:your-app.com/foo.js",
"updated_at": "2022-02-09T03:13:35.224Z",
"display_scope": "all"
}
]
}
Get script tags with a particular URL.
GET https://apis.haravan.com/web/script_tags.json?src=http://your-app-combo/foo.js
Details
HTTP/1.1 200 OK
{
"script_tags": [
{
"created_at": "2022-02-09T03:13:35.224Z",
"event": "onload",
"id": 1000132951,
"src": "https:your-app.com/foo.js",
"updated_at": "2022-02-09T03:13:35.224Z",
"display_scope": "all"
}
]
}
Receive a count of all ScriptTags.
Receive a count of all ScriptTags.
GET https://apis.haravan.com/web/script_tags/count.json
Details
HTTP/1.1 200 OK
{
"count": 1
}
Receive a single ScriptTag.
Get a single script tag by its ID.
GET https://apis.haravan.com/web/script_tags/1000132953.json
Details
HTTP/1.1 200 OK
{
"script_tag": {
"created_at": "2022-02-09T03:48:55.204Z",
"event": "onload",
"id": 1000132953,
"src": "http://your-app.com/foo.js",
"updated_at": "2022-02-09T03:48:55.204Z",
"display_scope": "all"
}
}
Create a new ScriptTag.
Create a new ScriptTag.
POST https://apis.haravan.com/web/script_tags.json
{
"script_tag": {
"event": "onload",
"src": "http://your-app.com/foo.js"
}
}
Details
HTTP/1.1 200 OK
{
"script_tag": {
"created_at": "2022-02-09T03:48:55.204Z",
"event": "onload",
"id": 1000132953,
"src": "http://your-app.com/foo.js",
"updated_at": "2022-02-09T03:48:55.204Z",
"display_scope": "all"
}
}
Modify an existing ScriptTag.
Update a script tags's URL.
PUT https://apis.haravan.com/web/script_tags/1000132953.json
{
"script_tag": {
"id": 1000132953,
"src": "http://your-app.com/another.js"
}
}
Details
HTTP/1.1 200 OK
{
"script_tag": {
"created_at": "2022-02-09T03:48:55.204Z",
"event": "onload",
"id": 1000132953,
"src": "http://your-app.com/another.js",
"updated_at": "2022-02-09T03:59:46.094Z",
"display_scope": "all"
}
}
Remove a ScriptTag.
Remove an existing script tag from a shop.
DELETE https://apis.haravan.com/web/script_tags/1000132953.json
{ }
Details
HTTP/1.1 200 OK
[]