# hasPiece

> **hasPiece**(`options`): [`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`boolean`\>

Defined in: [packages/synapse-core/src/sp/has-piece.ts:34](https://github.com/FilOzone/synapse-sdk/blob/5989c4b03ed2fe4cf8b1ef29efe1d4ff1ad4c7bc/packages/synapse-core/src/sp/has-piece.ts#L34)

Check whether a provider has a piece.

GET /pdp/piece?pieceCid={pieceCid}

A single [findPiece](/reference/filoz/synapse-core/sp/functions/findpiece/) lookup, without polling, that returns `false` instead of throwing when
the provider answers that it does not have the piece (404) or is still processing it (202).
Other failures, such as a 5xx response or a timeout, still throw, as does an abort.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `options` | [`OptionsType`](/reference/filoz/synapse-core/sp/namespaces/haspiece/type-aliases/optionstype/) | [hasPiece.OptionsType](/reference/filoz/synapse-core/sp/namespaces/haspiece/type-aliases/optionstype/) |

## Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`boolean`\>

Whether the provider has the piece [hasPiece.OutputType](/reference/filoz/synapse-core/sp/namespaces/haspiece/type-aliases/outputtype/)

## Example

```ts
import * as SP from '@filoz/synapse-core/sp'
import * as Piece from '@filoz/synapse-core/piece'

const found = await SP.hasPiece({
  serviceURL: 'https://pdp.example.com',
  pieceCid: Piece.from('bafkzcib...'),
})
```

## Throws

Errors [hasPiece.ErrorType](/reference/filoz/synapse-core/sp/namespaces/haspiece/type-aliases/errortype/)