> For the complete documentation index, see [llms.txt](https://docs.pgecom.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pgecom.com/api-endpoint/ecommerce/product/getproductbyslug.md).

# GetProductBySlug

In the example below, slug is set for the name for the product slug

<mark style="color:blue;">`GET`</mark> `https://sandbox.pgecom.com/api/v1/product/slug/{{slug}}`

#### Query Parameters

| Name                                     | Type   | Description     |
| ---------------------------------------- | ------ | --------------- |
| shopId<mark style="color:red;">\*</mark> | String | product shop id |

{% tabs %}
{% tab title="200: OK Success" %}

```json
[
    {
        "productType": "service",
        "published": false,
        "inventory": 20,
        "shopId": "9c4e8c79-b901-4b71-a305-0374664a0b65",
        "comparePrice": 0,
        "status": "active",
        "slug": "hair",
        "createdAt": "2023-11-04T02:04:51Z",
        "vendor": "pgecom",
        "name": "Hair",
        "isFeatured": false,
        "costPerItem": 0,
        "isContinueSellingOutStock": false,
        "userID": "5f56dfa3-a415-4818-8275-44fc63ece3fd",
        "updatedAt": "2023-11-04T02:04:51Z",
        "description": "Hair Product",
        "price": 50,
        "id": "b72b1e68-bb0d-48c2-ab85-ed0d24b7adfd",
        "mainImageUrl": "https://res.cloudinary.com/dnfoyqynm/image/upload/v1699063414/5f56dfa3-a415-4818-8275-44fc63ece3fd/pgecom/products/ebd7830c-f4aa-43fa-aeb4-ef2fedc4569e.jpg"
    }
]
```

{% endtab %}

{% tab title="500: Internal Server Error Internal Server Error" %}

```
{
    "message": "\"shopId\" is required",
    "status": 500
}
```

{% endtab %}

{% tab title="429: Too Many Requests Too many request" %}

```json
{
    "message": "Too many requests, please try again later.",
    "status": 429
}

```

{% endtab %}

{% tab title="404: Not Found Not found" %}

```
{
    "message": "Products with slug id hai not found",
    "status": 404
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Nodejs" %}

```javascript
const axios = require('axios');

let config = {
  method: 'get',
  url: 'https://sandbox.pgecom.com/api/v1/storefront/product/slug/hair?shopId=9c4e8c79-b901-4b71-a305-0374664a0b65',
  headers: { }
};

axios(config)
.then((response) => {
  console.log(JSON.stringify(response.data));
})
.catch((error) => {
  console.log(error);
});

```

{% endtab %}

{% tab title="Python" %}

```python
import http.client

conn = http.client.HTTPSConnection("localhost", 3002)
payload = ''
headers = {}
conn.request("GET", "/api/v1/storefront/product/slug/hair?shopId=9c4e8c79-b901-4b71-a305-0374664a0b65", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
```

{% endtab %}

{% tab title="Ruby" %}

```php
require "uri"
require "net/http"

url = URI("http://localhost:3002/api/v1/storefront/product/slug/hair?shopId=9c4e8c79-b901-4b71-a305-0374664a0b65")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body

```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('http://localhost:3002/api/v1/storefront/product/slug/hair?shopId=9c4e8c79-b901-4b71-a305-0374664a0b65');
$request->setMethod(HTTP_Request2::METHOD_GET);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}
```

{% endtab %}

{% tab title="Curl" %}

```
curl --location 'http://localhost:3002/api/v1/storefront/product/b72b1e68-bb0d-48c2-ab85-ed0d24b7adfd'
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.pgecom.com/api-endpoint/ecommerce/product/getproductbyslug.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
