PHPackages                             sminnee/stitchdata-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sminnee/stitchdata-php

ActiveLibrary[API Development](/categories/api)

sminnee/stitchdata-php
======================

PHP SDK for StitchData.com's Import API

0.2.1(5y ago)22.1k↓100%[1 issues](https://github.com/sminnee/stitchdata-php/issues)BSD-3-ClausePHPPHP &gt;=5.6

Since Jun 26Pushed 5y agoCompare

[ Source](https://github.com/sminnee/stitchdata-php)[ Packagist](https://packagist.org/packages/sminnee/stitchdata-php)[ RSS](/packages/sminnee-stitchdata-php/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (1)Versions (7)Used By (0)

stitchdata-php
==============

[](#stitchdata-php)

PHP SDK for StitchData.com's [Import API](https://www.stitchdata.com/docs/integrations/import-api).

Installation
------------

[](#installation)

This is a [Composer](https://getcomposer.org/) library, and can be installed with `composer require`. The current release is `^0.1`

```
composer require sminnee/stitchdata-php:^0.1

```

Usage
-----

[](#usage)

### new StitchApi(string $clientId, string $accessToken)

[](#new-stitchapistring-clientid-string-accesstoken)

The `Sminnee\StitchData\StitchApi` class provides access to the API. Its constructor takes 2 arguments, which are described in the [Import API documentation](https://www.stitchdata.com/docs/integrations/import-api#auth).

```
use Sminnee\StitchData\StitchApi;
$api = new StitchApi(getenv('STITCHDATA_CLIENT_ID'), getenv('STITCHDATA_ACCESS_TOKEN'));
```

### StitchApi::validate(array $data = null, $includeClientId = true)

[](#stitchapivalidatearray-data--null-includeclientid--true)

Validates that the connection is working and that your credentials are correct.

- Validates the content (`$data`) of a request. It must be an array of maps.
- If `$data` is omitted, a dummy request will be provided, including the client ID
- If `$includeClientId` is true, then a `client_id` property will be added to every record in data, unless it is already specified.

```
// Throws an exception if there's an issue with our connection
$api->validate();
```

### StitchApi::pushRecords(string $tableName, array $keyNames, iterable $records, int $batchSize = 100, ?callable $onBatchSent = null)

[](#stitchapipushrecordsstring-tablename-array-keynames-iterable-records-int-batchsize--100-callable-onbatchsent--null)

Pushes a number of records to the API in 1 or more batches.

- `$tableName` is the name of the table in your data warehouse that you wnat StitchData to create and/or write to. It will populate `table_name` in requests to the API.
- `$keyNames` is an array of record keys that you want to collectively use are your primary key. It will populate `key_names` in requests to the API.
- `$records` is an array or iterator of records, where each record is a map. This is the data to upsert.
- `$batchSize`, which defaults to 100, is the maximum number of records ot include in a single API request.
- `$onBatchSent`, a callback that will be called, passing an array of all sent records, once per successful API call. This can be especially helpful when passing a generator for the data, as you can make subsequent use of the data without separately iterating on it.

The Data types you can use are determined by the [Transit library's default type mapping](https://github.com/honzabrecka/transit-php#default-type-mapping). Notably, you should use `Datetime` objects to represents dates/times.

```
// Push 2 records to the StitchData, upserting in your data warehouse, and creating the test_peopel table if needed
$api->pushRecords(
    'test_people',
    [' id' ],
    [
        [
            "id" => 1,
            "first_name" => "Sam",
            "last_name" => "Minnee",
            "num_visits" => 3,
            "date_last_visit" => new Datetime("2018-06-26"),
        ],
        [
            "id" => 2,
            "first_name" => "Ingo",
            "last_name" => "Schommer",
            "num_visits" => 6,
            "date_last_visit" => new Datetime("2018-06-27"),
        ]
   ]
);
```

### StitchApi::apiCall($subUrl, $data, $includeClientId = true)

[](#stitchapiapicallsuburl-data-includeclientid--true)

Raw call to the StitchData REST API. Where possible we recommend that you use the above methods, but this allows for accessing new API behaviour not yet supported the SDK.

Sequence generation
-------------------

[](#sequence-generation)

Sequence IDs are an important part of interacting with the API. `pushRecords()` automatically generates sequence IDs by the following mechanism.

- The first request will use a sequence ID of `time() * 1000`.
- Subquent requests will use the greater of sequence ID + 1 or time() \* 1000.

If you wish to manually generate your own sequnce IDs you have to use the apiCall method instead, but please raise a github issue describing your use-case!

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~192 days

Recently: every ~240 days

Total

6

Last Release

1920d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/be6648e60fbab6f70bfc34dd8c14259562d28a47510a934ea9c01fe98633f3c2?d=identicon)[sminnee](/maintainers/sminnee)

### Embed Badge

![Health badge](/badges/sminnee-stitchdata-php/health.svg)

```
[![Health](https://phpackages.com/badges/sminnee-stitchdata-php/health.svg)](https://phpackages.com/packages/sminnee-stitchdata-php)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
