PHPackages                             facturapi/facturapi-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. facturapi/facturapi-php

ActiveLibrary[API Development](/categories/api)

facturapi/facturapi-php
=======================

Facturapi's PHP client library

3.6.0(3mo ago)1543.5k↑92.2%11[2 issues](https://github.com/FacturAPI/facturapi-php/issues)MITPHPPHP &gt;=5.5.0CI failing

Since Jan 26Pushed 3mo ago4 watchersCompare

[ Source](https://github.com/FacturAPI/facturapi-php)[ Packagist](https://packagist.org/packages/facturapi/facturapi-php)[ Docs](https://www.facturapi.io/)[ RSS](/packages/facturapi-facturapi-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (48)Used By (0)

Facturapi PHP Library
=====================

[](#facturapi-php-library)

This is the official PHP wrapper for

FacturAPI makes it easy for developers to generate valid Invoices in Mexico (known as Factura Electrónica or CFDI).

If you've ever used [Stripe](https://stripe.com) or [Conekta](https://conekta.io), you'll find FacturAPI very straightforward to understand and integrate in your server app.

Install
-------

[](#install)

```
composer require "facturapi/facturapi-php"
```

Before you begin
----------------

[](#before-you-begin)

Make sure you have created your free account on [FacturAPI](https://www.facturapi.io) and that you have your **API Keys**.

Getting started
---------------

[](#getting-started)

### Import the library

[](#import-the-library)

Don't forget to reference the library at the top of your code:

```
use Facturapi\Facturapi;
```

### Create a customer

[](#create-a-customer)

```
// Create an instance of the client.
// You can use different instances for uusing different API Keys
$facturapi = new Facturapi( FACTURAPI_KEY );

$customer = array(
  "email" => "walterwhite@gmail.com", //Optional but useful to send invoice by email
  "legal_name" => "Walter White", // Razón social
  "tax_id" => "WIWA761018", //RFC
  "address" => array(
    "zip"=> "06800",
    "street" => "Av. de los Rosales",
    "exterior" => "123",
    "neighborhood" => "Tepito"
    // city, municipality and state are filled automatically from the zip code
    // but if you want to, you can override their values
    // city: 'México',
    // municipality: 'Cuauhtémoc',
    // state: 'Ciudad de México'
  )
);

// Remember to store the customer.id in your records.
// You will need it to create an invoice for this customer.
$new_customer = $facturapi->Customers->create($customer);
```

### Create a product

[](#create-a-product)

```
$facturapi = new Facturapi( FACTURAPI_KEY );
$product = array(
  "product_key" => "4319150114", // Clave Producto/Servicio from SAT's catalog. Log in to FacturAPI and use our tool to look it up.
  "description" => "Apple iPhone 8",
  "price"       => 345.60 // price in MXN.
  // By default, taxes are calculated from the price with IVA 16%
  // But again, you can override that by explicitly providing a taxes array
  // "taxes" => array(
  //   array ( "type" => \Facturapi\TaxType::IVA, "rate" => 0.16 ),
  //   array ( "type" => \Facturapi\TaxType::ISR, "rate" => 0.03666, "withholding" => true )
  // )
);

$facturapi->Products->create( $product );
```

### Create an invoice

[](#create-an-invoice)

```
$facturapi = new Facturapi( FACTURAPI_KEY );

$invoice = array(
  "customer"     => "YOUR_CUSTOMER_ID",
  "items"        => array(
    array(
      "quantity" => 1, // Optional. Defaults to 1.
      "product"  => "YOUR_PRODUCT_ID" // You can also pass a product object instead
    ),
    array(
      "quantity" => 2,
        "product"  => array(
        "description" => "Guitarra",
        "product_key" => "01234567",
        "price"       => 420.69,
        "sku"         => "ABC4567"
      )
    ) // Add as many products as you want to include in your invoice
  ),
  "payment_form" => \Facturapi\PaymentForm::EFECTIVO,
  "folio_number" => "581",
  "series"       => "F"
);

$facturapi->Invoices->create( $invoice );
```

#### Download your invoice

[](#download-your-invoice)

```
// Once you have successfully created your invoice, you can...
$facturapi = new Facturapi( FACTURAPI_KEY );

$facturapi->Invoices->download_zip("INVOICE_ID") // stream containing the PDF and XML as a ZIP file or

$facturapi->Invoices->download_pdf("INVOICE_ID") // stream containing the PDF file or

$facturapi->Invoices->download_xml("INVOICE_ID") // stream containing the XML file or
```

#### Send your invoice by email

[](#send-your-invoice-by-email)

```
// Send the invoice to your customer's email (if any)
$facturapi = new Facturapi( FACTURAPI_KEY );

$facturapi->Invoices->send_by_email("INVOICE_ID");
```

Documentation
-------------

[](#documentation)

There's more you can do with this library: List, retrieve, update, and remove Customers, Products and Invoices.

Visit the full documentation at .

Help
----

[](#help)

### Found a bug?

[](#found-a-bug)

Please report it on the Issue Tracker

### Want to contribute?

[](#want-to-contribute)

Send us your PR! We appreciate your help :)

### Contact us!

[](#contact-us)

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance76

Regular maintenance activity

Popularity40

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~88 days

Total

34

Last Release

116d ago

Major Versions

1.7.0 → 2.0.02022-01-31

2.7.1 → 3.0.02024-06-26

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2592262?v=4)[Javier Rosas](/maintainers/javorosas)[@javorosas](https://github.com/javorosas)

---

Top Contributors

[![javorosas](https://avatars.githubusercontent.com/u/2592262?v=4)](https://github.com/javorosas "javorosas (27 commits)")[![raul-facturapi](https://avatars.githubusercontent.com/u/141654545?v=4)](https://github.com/raul-facturapi "raul-facturapi (24 commits)")[![jl4guna](https://avatars.githubusercontent.com/u/7268524?v=4)](https://github.com/jl4guna "jl4guna (22 commits)")[![eichgi](https://avatars.githubusercontent.com/u/9018836?v=4)](https://github.com/eichgi "eichgi (1 commits)")[![ingfdoaguirre](https://avatars.githubusercontent.com/u/19358221?v=4)](https://github.com/ingfdoaguirre "ingfdoaguirre (1 commits)")[![wrtisans](https://avatars.githubusercontent.com/u/44764875?v=4)](https://github.com/wrtisans "wrtisans (1 commits)")

---

Tags

apisatcfdimexicofacturafacturapi

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpcfdi/sat-ws-descarga-masiva

Librería para usar el servicio web del SAT de Descarga Masiva

16663.6k3](/packages/phpcfdi-sat-ws-descarga-masiva)[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.0k](/packages/m165437-laravel-blueprint-docs)[phpcfdi/cfdi-sat-scraper

Web Scraping para extraer facturas electrónicas desde la página del SAT

9018.0k](/packages/phpcfdi-cfdi-sat-scraper)[phpcfdi/cfditopdf

Create a generic PDF file from a CFDI 3.3 &amp; 4.0 (CLI included)

4144.3k4](/packages/phpcfdi-cfditopdf)[phpcfdi/finkok

Librería para conectar con la API de servicios de FINKOK

2012.2k](/packages/phpcfdi-finkok)[phpcfdi/cfdi-to-json

Convert CFDI to JSON

3120.0k2](/packages/phpcfdi-cfdi-to-json)

PHPackages © 2026

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