Analytics Types

AnalyticsQuery

type AnalyticsQuery = {
  gateway_domain: string;
  start_date: string;
  end_date: string;
  cid?: string;
  file_name?: string;
  user_agent?: string;
  country?: string;
  region?: string;
  referer?: string;
  limit?: number;
  sort_order?: "asc" | "desc";
};

TopAnalyticsQuery

type TopAnalyticsQuery = AnalyticsQuery & {
  sort_by: "requests" | "bandwidth";
  attribute: "cid" | "country" | "region" | "user_agent" | "referer" | "file_name";
};

TopAnalyticsResponse

type TopAnalyticsResponse = {
  data: TopAnalyticsItem[];
};

TopAnalyticsItem

type TopAnalyticsItem = {
  value: string;
  requests: number;
  bandwidth: number;
};

TimeIntervalAnalyticsQuery

type TimeIntervalAnalyticsQuery = AnalyticsQuery & {
  sort_by?: "requests" | "bandwidth";
  date_interval: "day" | "week";
};

TimePeriodItem

type TimePeriodItem = {
  period_start_time: string;
  requests: number;
  bandwidth: number;
};

TimeIntervalAnalyticsResponse

type TimeIntervalAnalyticsResponse = {
  total_requests: number;
  total_bandwidth: number;
  time_periods: TimePeriodItem[];
};

UserPinnedDataResponse

type UserPinnedDataResponse = {
  pin_count: number;
  pin_size_total: number;
  pin_size_with_replications_total: number;
};

Config Types

PinataConfig

type PinataConfig = {
  pinataJwt?: string;
  pinataGateway?: string;
  pinataGatewayKey?: string;
  customHeaders?: Record<string, string>;
  endpointUrl?: string;
  uploadUrl?: string;
};

File Types

FileObject

type FileObject = {
  name: string;
  size: number;
  type: string;
  lastModified: number;
  arrayBuffer: () => Promise<ArrayBuffer>;
};

JsonBody

type JsonBody = Record<string, unknown>;

PinataMetadata

type PinataMetadata = {
  name?: string;
  keyvalues?: Record<string, string>;
};

UpdateFileOptions

type UpdateFileOptions = {
  id: string;
  name?: string;
  keyvalues?: Record<string, string>;
};

DeleteResponse

type DeleteResponse = {
  id: string;
  status: string;
};

FileListItem

type FileListItem = {
  id: string;
  name: string | null;
  cid: "pending" | string;
  size: number;
  number_of_files: number;
  mime_type: string;
  keyvalues: Record<string, string>;
  group_id: string | null;
  created_at: string;
};

FileListResponse

type FileListResponse = {
  files: FileListItem[];
  next_page_token: string;
};

FileListQuery

type FileListQuery = {
  name?: string;
  group?: string;
  noGroup?: boolean;
  mimeType?: string;
  cid?: string;
  cidPending?: boolean;
  metadata?: Record<string, string>;
  order?: "ASC" | "DESC";
  limit?: number;
  pageToken?: string;
};

PinQueueQuery

type PinQueueQuery = {
  sort?: "ASC" | "DSC";
  status?: "prechecking" | "retrieving" | "expired" | "backfilled" | "over_free_limit" | "over_max_size" | "invalid_object" | "bad_host_node";
  cid?: string;
  limit?: number;
  pageToken?: string;
};

PinQueueItem

type PinQueueItem = {
  id: string;
  cid?: string;
  ipfs_pin_hash?: string;
  date_queued: string;
  name: string;
  status: string;
  keyvalues: any;
  host_nodes: string[];
  pin_policy: {
    regions: {
      id: string;
      desiredReplicationCount: number;
    }[];
    version: number;
  };
};

PinQueueResponse

type PinQueueResponse = {
  rows: PinQueueItem[];
  next_page_token: string;
};

SwapCidOptions

type SwapCidOptions = {
  cid: string;
  swapCid: string;
};

SwapHistoryOptions

type SwapHistoryOptions = {
  cid: string;
  domain: string;
};

SwapCidResponse

type SwapCidResponse = {
  mapped_cid: string;
  created_at: string;
};

VectorizeFileResponse

type VectorizeFileResponse = {
  status: boolean;
};

VectorizeQuery

type VectorizeQuery = {
  groupId: string;
  query: string;
  returnFile?: boolean;
};

VectorQueryMatch

type VectorQueryMatch = {
  file_id: string;
  cid: string;
  score: number;
};

VectorizeQueryResponse

type VectorizeQueryResponse = {
  count: number;
  matches: VectorQueryMatch[];
};

Gateway Types

ContentType

type ContentType =
  | "application/json"
  | "application/xml"
  | "text/plain"
  | "text/html"
  | "text/css"
  | "text/javascript"
  | "application/javascript"
  | "image/jpeg"
  | "image/png"
  | "image/gif"
  | "image/svg+xml"
  | "audio/mpeg"
  | "audio/ogg"
  | "video/mp4"
  | "application/pdf"
  | "application/octet-stream"
  | string
  | null;

GetCIDResponse

type GetCIDResponse = {
  data?: JSON | string | Blob | null;
  contentType: ContentType;
};

OptimizeImageOptions

type OptimizeImageOptions = {
  width?: number;
  height?: number;
  dpr?: number;
  fit?: "scaleDown" | "contain" | "cover" | "crop" | "pad";
  gravity?: "auto" | "side" | string;
  quality?: number;
  format?: "auto" | "webp";
  animation?: boolean;
  sharpen?: number;
  onError?: boolean;
  metadata?: "keep" | "copyright" | "none";
};

AccessLinkOptions

type AccessLinkOptions = {
  cid: string;
  date?: number;
  expires: number;
  gateway?: string;
};

ContainsCIDResponse

type ContainsCIDResponse = {
  containsCid: boolean;
  cid: string | null;
};

Group Types

GroupOptions

type GroupOptions = {
  name: string;
  isPublic?: boolean;
};

UpdateGroupOptions

type UpdateGroupOptions = {
  groupId: string;
  name?: string;
  isPublic?: boolean;
};

GetGroupOptions

type GetGroupOptions = {
  groupId: string;
};

GroupListResponse

type GroupListResponse = {
  groups: GroupResponseItem[];
  next_page_token: string;
};

GroupResponseItem

type GroupResponseItem = {
  id: string;
  is_public: boolean;
  name: string;
  createdAt: string;
};

GroupQueryOptions

type GroupQueryOptions = {
  name?: string;
  limit?: number;
  pageToken?: string;
  isPublic?: boolean;
};

GroupCIDOptions

type GroupCIDOptions = {
  groupId: string;
  files: string[];
};

UpdateGroupFilesResponse

type UpdateGroupFilesResponse = {
  id: string;
  status: string;
};

Key Types

KeyPermissions

type KeyPermissions = {
  admin?: boolean;
  endpoints?: Endpoints;
  resources?: ResourcePermission[];
};

ResourcePermission

type ResourcePermission =
  | "org:read"
  | "org:write"
  | "org:files:read"
  | "org:files:write"
  | "org:groups:read"
  | "org:groups:write"
  | "org:gateways:read"
  | "org:gateways:write"
  | "org:analytics:read"
  | "org:analytics:write";

Endpoints

type Endpoints = {
  data?: DataEndponts;
  pinning?: PinningEndpoints;
};

DataEndponts

type DataEndponts = {
  pinList?: boolean;
  userPinnedDataTotal?: boolean;
};

PinningEndpoints

type PinningEndpoints = {
  hashMetadata?: boolean;
  hashPinPolicy?: boolean;
  pinByHash?: boolean;
  pinFileToIPFS?: boolean;
  pinJSONToIPFS?: boolean;
  pinJobs?: boolean;
  unpin?: boolean;
  userPinPolicy?: boolean;
};

KeyOptions

type KeyOptions = {
  keyName: string;
  permissions: KeyPermissions;
  maxUses?: number;
};

KeyResponse

type KeyResponse = {
  JWT: string;
  pinata_api_key: string;
  pinata_api_secret: string;
};

KeyListQuery

type KeyListQuery = {
  revoked?: boolean;
  limitedUse?: boolean;
  exhausted?: boolean;
  name?: string;
  offset?: number;
};

KeyListItem

type KeyListItem = {
  id: string;
  name: string;
  key: string;
  secret: string;
  max_uses: number;
  uses: number;
  user_id: string;
  scopes: KeyScopes;
  revoked: boolean;
  createdAt: string;
  updatedAt: string;
};

KeyScopes

type KeyScopes = {
  endpoints: {
    pinning: {
      pinFileToIPFS: boolean;
      pinJSONToIPFS: boolean;
    };
  };
  admin: boolean;
};

KeyListResponse

type KeyListResponse = {
  keys: KeyListItem[];
  count: number;
};

RevokeKeyResponse

type RevokeKeyResponse = {
  key: string;
  status: string;
};

Signature Types

SignatureOptions

type SignatureOptions = {
  cid: string;
  signature: string;
  address: string;
};

SignatureResponse

type SignatureResponse = {
  cid: string;
  signature: string;
};

Upload Types

UploadResponse

type UploadResponse = {
  id: string;
  name: string;
  cid: string;
  size: number;
  created_at: string;
  number_of_files: number;
  mime_type: string;
  group_id: string | null;
  keyvalues: {
    [key: string]: string;
  };
  vectorized: boolean;
  network: string;
};

UploadOptions

type UploadOptions = {
  metadata?: PinataMetadata;
  keys?: string;
  groupId?: string;
  vectorize?: boolean;
  url?: string;
  peerAddresses?: string[];
};

SignedUploadUrlOptions

type SignedUploadUrlOptions = {
  date?: number;
  expires: number;
  groupId?: string;
  name?: string;
  keyvalues?: Record<string, string>;
  vectorize?: boolean;
  maxFileSize?: number;
  mimeTypes?: string[];
};

UploadCIDOptions

type UploadCIDOptions = {
  metadata?: PinataMetadata;
  peerAddresses?: string[];
  keys?: string;
  groupId?: string;
};

PinByCIDResponse

type PinByCIDResponse = {
  id: string;
  cid: string;
  date_queued: string;
  name: string;
  status: string;
  keyvalues: Record<string, any> | null;
  host_nodes: string[] | null;
  group_id: string | null;
};