Attribute

Retrieve attributes available in the shop. Attributes can be attached to one or more specifications. This may be used to describe the specifications of a product and compare two products based on their attributes.

Example object

{
  "attribute": {
    "id": 15992,
    "title": "Camera",
    "defaultValue": "Nikon",
    "types": {
      "resource": {
        "id": false,
        "url": "types/attributes?type=15992",
        "link": "https://api.shoplightspeed.com/en/types/attributes.json?attribute=15992"
      }
    }
  }
}

Properties

id The unique numeric identifier for the attribute. {“id”: {id}}
title Title of the attribute. {“title”: “Camera”}
defaultValue Default value for the attribute. The actual value may be overwritten for each product. {“defaultValue”: “Nikon”}
types Link to TypesAttribute resource. {“types”: “types/attributes?type=15992”}

GET All attributes

Retrieve all attribute objects available in the shop. Attributes may belong to multiple specifications.

Definition

GET /attributes.json

Example request

curl https://api.shoplightspeed.com/en/attributes.json \
  -u {key}:{secret}
<?php $api->attributes->get();

Example response

{
  "attributes": [
    {
      "id": 15992,
      "title": "Camera",
      "defaultValue": "Nikon",
      "types": {
        "resource": {
          "id": false,
          "url": "types/attributes?type=15992",
          "link": "https://api.shoplightspeed.com/en/types/attributes.json?attribute=15992"
        }
      }
    },
    {
      "id": 15990,
      "title": "Megapixel",
      "defaultValue": "3.5",
      "types": {
        "resource": {
          "id": false,
          "url": "types/attributes?type=15990",
          "link": "https://api.shoplightspeed.com/en/types/attributes.json?attribute=15990"
        }
      }
    },
    {
      "id": 15989,
      "title": "Includes a bag",
      "defaultValue": "no",
      "types": {
        "resource": {
          "id": false,
          "url": "types/attributes?type=15989",
          "link": "https://api.shoplightspeed.com/en/types/attributes.json?attribute=15989"
        }
      }
    }
  ]
}

Arguments

  No arguments available.

Filters

limit Number of results. {(default: 50) (maximum: 250)}
page Page to show. {(default: 1)}
since_id Restrict results to after the specified ID. {(default: 0)}
fields Comma-separated list of fields to include in the response. {(format: id,createdAt)}

GET Number of attributes

Retrieve the number of attribute objects available in the shop.

Definition

GET /attributes/count.json

Example request

curl https://api.shoplightspeed.com/en/attributes/count.json \
  -u {key}:{secret}
<?php $api->attributes->count();

Example response

{
  "count": 10
}

Arguments

  No arguments available.

Filters

limit Number of results. {(default: 50) (maximum: 250)}
page Page to show. {(default: 1)}
since_id Restrict results to after the specified ID. {(default: 0)}
fields Comma-separated list of fields to include in the response. {(format: id,createdAt)}

GET Single attribute

Returns a single attribute by its unique identifier.

Definition

GET /attributes/{attribute_id}.json

Example request

curl https://api.shoplightspeed.com/en/attributes/{attribute_id}.json \
  -u {key}:{secret}
<?php $api->attributes->get($attribute_id);

Example response

{
  "attribute": {
    "id": 15992,
    "title": "Camera",
    "defaultValue": "Nikon",
    "types": {
      "resource": {
        "id": false,
        "url": "types/attributes?type=15992",
        "link": "https://api.shoplightspeed.com/en/types/attributes.json?attribute=15992"
      }
    }
  }
}

Arguments

id The unique numeric identifier for the attribute. {“id”: {id}}

POST Create an attribute

Create a new attribute based on the given parameters.

Definition

POST /attributes.json

Example request

curl -X POST https://api.shoplightspeed.com/en/attributes.json \
  -u {key}:{secret} \
  -d attribute[title]="Camera" \
  -d attribute[defaultValue]="Nikon"
<?php $api->attributes->create([
  "title"        => "Camera",
  "defaultValue" => "Nikon"
]);

Example Json payload

{
  "attribute": {
    "title": "Camera",
    "defaultValue": "Nikon"
  }
}

Example response

{
  "attribute": {
    "id": 15992,
    "title": "Camera",
    "defaultValue": "Nikon",
    "types": {
      "resource": {
        "id": false,
        "url": "types/attributes?type=15992",
        "link": "https://api.shoplightspeed.com/en/types/attributes.json?attribute=15992"
      }
    }
  }
}

Arguments

title Title of the attribute. {“title”: “Camera”}
defaultValue Default value for the attribute. The actual value may be overwritten for each product. {“defaultValue”: “Nikon”}

PUT Update an attribute

Update an existing attribute based on the given parameters.

Definition

PUT /attributes/{attribute_id}.json

Example request

curl -X PUT https://api.shoplightspeed.com/en/attributes/{attribute_id}.json \
  -u {key}:{secret} \
  -d attribute[title]="Camera" \
  -d attribute[defaultValue]="Nikon"
<?php $api->attributes->update($attribute_id, [
  "title"        => "Camera",
  "defaultValue" => "Nikon"
]);

Example Json payload

{
  "attribute": {
    "title": "Camera",
    "defaultValue": "Nikon"
  }
}

Example response

{
  "attribute": {
    "id": 15992,
    "title": "Camera",
    "defaultValue": "Nikon",
    "types": {
      "resource": {
        "id": false,
        "url": "types/attributes?type=15992",
        "link": "https://api.shoplightspeed.com/en/types/attributes.json?attribute=15992"
      }
    }
  }
}

Arguments

title Title of the attribute. {“title”: “Camera”}
defaultValue Default value for the attribute. The actual value may be overwritten for each product. {“defaultValue”: “Nikon”}

DELETE Delete an attribute

Delete an existing attribute that is associated with the API key used to perform the request.

Definition

DELETE /attributes/{attribute_id}.json

Example request

curl -X DELETE https://api.shoplightspeed.com/en/attributes/{attribute_id}.json \
  -u {key}:{secret}
<?php $api->attributes->delete($attribute_id);

Example response

HTTP/1.1 204 No Content

Arguments

id The unique numeric identifier for the attribute. {“id”: {id}}