meisam-mulla/laravel-openfda

Simplified OpenFDA API for Laravel

1.0.5 2023-06-19 18:09 UTC

This package is auto-updated.

Last update: 2024-05-19 20:14:20 UTC


README

The Laravel OpenFDA package simplifies accessing the openFDA APIs, allowing users to query the API with ease. While this package is designed to be used with Laravel, it can also be used independently.

You can use this API without an API key however you will be limited to 1,000 requests per day. You can get a free API key from openFDA directly

Installation

You can install the Laravel OpenFDA package via Composer by running the following command:

composer require meisam-mulla/laravel-openfda

Usage

To use the Laravel OpenFDA package, follow the example below:

With Laravel

$response = OpenFDA::search('tylenol')->get();

// Process the response

Without Laravel

use MeisamMulla\OpenFDA\OpenFDA;

$openFDA = new OpenFDA();

$response = $openFDA->search('tylenol')->get();

// Process the response

Available Methods

The following methods are available for querying the openFDA APIs:

Method Description
use(string $endpoint): OpenFDA Set the API endpoint to be used.
search(string $query): OpenFDA Set the search query.
sort(string $sort): OpenFDA Set the sorting criteria.
count(int $count): OpenFDA Set the number of results to be counted.
limit(int $limit): OpenFDA Set the maximum number of results to be returned.
skip(int $skip): OpenFDA Set the number of results to skip.
get(): stdClass Send the API request and retrieve the response.

Available Endpoints

The Laravel OpenFDA package provides access to the following openFDA API endpoints:

Endpoint Description
ANIMAL_DRUG_EVENT Animal and Veterinary Drug Event
DRUG_EVENT Drug Event
DRUG_LABEL Drug Label
DRUG_NDC Drug NDC
DRUG_ENFORCEMENT Drug Enforcement
DRUG_FDA Drug FDA
DEVICE_501K Device 510k
DEVICE_CLASSIFICATION Device Classification
DEVICE_ENFORCEMENT Device Enforcement
DEVICE_EVENT Device Event
DEVICE_PMA Device PMA
DEVICE_RECALL Device Recall
DEVICE_REGISTRATION Device Registration Listing
DEVICE_COVID19 Device COVID-19 Serology
DEVICE_UDI Device UDI
FOOD_ENFORCEMENT Food Enforcement
FOOD_EVENT Food Event
TOBACCO_PROBLEM Tobacco Problem

Configuration

To configure the package, you can set the OPENFDA_APIKEY variable in your .env file. If the variable is set, it will be included as an authorization header in the API requests.

You can use this API without an API key however you will be limited to 1,000 requests per day. You can get a free API key from openFDA directly

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue on GitHub.

License

The Laravel OpenFDA package is open-source software licensed under the MIT license.

Acknowledgements

This package is built upon the openFDA APIs. We would like to express our gratitude to the openFDA team for providing this valuable resource.

Contact

If you have any questions or need further assistance, feel free to contact the package maintainer at mmeisam@gmail.com.