C Stripe: List all Events

Back to Index

List events, going back up to 30 days.

Documentation: https://stripe.com/docs/api/curl#list_events

CURL Command

curl https://api.stripe.com/v1/events?limit=3 \
   -u STRIPE_SECRET_KEY: \
   -G

C Example

#include <C_CkRest.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkRest rest;
    BOOL success;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jsonResponse;
    const char *object;
    const char *url;
    BOOL has_more;
    int i;
    int count_i;
    const char *id;
    BOOL api_version;
    int created;
    const char *dataObjectId;
    const char *dataObjectObject;
    int dataObjectAmount;
    int dataObjectCreated;
    const char *dataObjectCurrency;
    const char *dataObjectInterval;
    int dataObjectInterval_count;
    BOOL dataObjectLivemode;
    const char *dataObjectName;
    BOOL dataObjectStatement_descriptor;
    BOOL dataObjectTrial_period_days;
    BOOL livemode;
    int pending_webhooks;
    BOOL requestId;
    BOOL requestIdempotency_key;
    const char *type;

    rest = CkRest_Create();

    //  URL: https://api.stripe.com/v1/events?limit=3
    bTls = TRUE;
    port = 443;
    bAutoReconnect = TRUE;
    success = CkRest_Connect(rest,"api.stripe.com",port,bTls,bAutoReconnect);
    if (success != TRUE) {
        printf("ConnectFailReason: %d\n",CkRest_getConnectFailReason(rest));
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        return;
    }

    CkRest_SetAuthBasic(rest,"STRIPE_SECRET_KEY","");

    sbResponseBody = CkStringBuilder_Create();
    success = CkRest_FullRequestNoBodySb(rest,"GET","/v1/events?limit=3",sbResponseBody);
    if (success != TRUE) {
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        CkStringBuilder_Dispose(sbResponseBody);
        return;
    }

    jsonResponse = CkJsonObject_Create();
    CkJsonObject_LoadSb(jsonResponse,sbResponseBody);

    object = CkJsonObject_stringOf(jsonResponse,"object");
    url = CkJsonObject_stringOf(jsonResponse,"url");
    has_more = CkJsonObject_BoolOf(jsonResponse,"has_more");
    i = 0;
    count_i = CkJsonObject_SizeOfArray(jsonResponse,"data");
    while (i < count_i) {
        CkJsonObject_putI(jsonResponse,i);
        id = CkJsonObject_stringOf(jsonResponse,"data[i].id");
        object = CkJsonObject_stringOf(jsonResponse,"data[i].object");
        api_version = CkJsonObject_IsNullOf(jsonResponse,"data[i].api_version");
        created = CkJsonObject_IntOf(jsonResponse,"data[i].created");
        dataObjectId = CkJsonObject_stringOf(jsonResponse,"data[i].data.object.id");
        dataObjectObject = CkJsonObject_stringOf(jsonResponse,"data[i].data.object.object");
        dataObjectAmount = CkJsonObject_IntOf(jsonResponse,"data[i].data.object.amount");
        dataObjectCreated = CkJsonObject_IntOf(jsonResponse,"data[i].data.object.created");
        dataObjectCurrency = CkJsonObject_stringOf(jsonResponse,"data[i].data.object.currency");
        dataObjectInterval = CkJsonObject_stringOf(jsonResponse,"data[i].data.object.interval");
        dataObjectInterval_count = CkJsonObject_IntOf(jsonResponse,"data[i].data.object.interval_count");
        dataObjectLivemode = CkJsonObject_BoolOf(jsonResponse,"data[i].data.object.livemode");
        dataObjectName = CkJsonObject_stringOf(jsonResponse,"data[i].data.object.name");
        dataObjectStatement_descriptor = CkJsonObject_IsNullOf(jsonResponse,"data[i].data.object.statement_descriptor");
        dataObjectTrial_period_days = CkJsonObject_IsNullOf(jsonResponse,"data[i].data.object.trial_period_days");
        livemode = CkJsonObject_BoolOf(jsonResponse,"data[i].livemode");
        pending_webhooks = CkJsonObject_IntOf(jsonResponse,"data[i].pending_webhooks");
        requestId = CkJsonObject_IsNullOf(jsonResponse,"data[i].request.id");
        requestIdempotency_key = CkJsonObject_IsNullOf(jsonResponse,"data[i].request.idempotency_key");
        type = CkJsonObject_stringOf(jsonResponse,"data[i].type");
        i = i + 1;
    }



    CkRest_Dispose(rest);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jsonResponse);

    }

Sample JSON Response Body

{
  "object": "list",
  "url": "/v1/events",
  "has_more": false,
  "data": [
    {
      "id": "evt_1BnETJGswQrCoh0XAl7jSmFB",
      "object": "event",
      "api_version": null,
      "created": 1516662781,
      "data": {
        "object": {
          "id": "gold",
          "object": "plan",
          "amount": 2000,
          "created": 1516662781,
          "currency": "usd",
          "interval": "month",
          "interval_count": 1,
          "livemode": false,
          "metadata": {},
          "name": "T-shirt",
          "statement_descriptor": null,
          "trial_period_days": null
        }
      },
      "livemode": false,
      "pending_webhooks": 0,
      "request": {
        "id": null,
        "idempotency_key": null
      },
      "type": "plan.created"
    }
  ]
}