# API reference

## Encoding

## Decoding

## Types

cbor2.undefined

  A singleton representing the CBOR “undefined” value.

## Type aliases

type SemanticDecoderCallback = Callable[[Any, bool], Any]

  The common type of callbacks accepted in the `semantic_decoders` decoder option.

type ShareableDecoderInitializer = Callable[[bool], tuple[Any, ShareableDecoderCallback]]

  A two-phase decoder callback accepted in the `semantic_decoders` decoder option.

type ShareableDecoderCallback = Callable[[Any], Any]

  Type of the callback returned by a `ShareableDecoderInitializer`

type ObjectHook = Callable[[collections.abc.Mapping[Any, Any]], Any]

  Type of the callback needed for the `object_hook` decoder option.

type TagHook = Callable[[CBORTag], Any]

  Type of the callback needed for the `tag_hook` decoder option.

type EncoderHook = Callable[[CBOREncoder, Any], Any]

  Type of the callback needed for the `default` encoder option.

## Exceptions