Code Monkey home page Code Monkey logo

tineye-api-php's Introduction

TinEye API PHP Library

tineye-api is a PHP library for the TinEye API. The TinEye API is a paid reverse image search solution for professional, commercial or high-volume users of TinEye.

Contents

Installation

Install via Composer. If composer is installed, run the following from your shell:

$ composer require tineye/tineye-api

Getting started

Once you've installed the library, you can instantiate a TinEyeApi object with your private and public keys:

<?php
$tineyeapi = new tineye\api\TinEyeApi(<Private_API_Key>,<Public_API_Key>);

If you don't have an account yet, you can still test out the library using our API sandbox by instantiating the TinEyeApi object with no arguments:

<?php
$tineyeapi = new tineye\api\TinEyeApi();

Note that the API sandbox will not return real results; all results will be the same image of a cat.

Once you've created your TinEyeApi object you can start searching. You can submit an image using either an image URL or by submitting image data by uploading an image file. You can also check the number of remaining searches in your account or check the number of images in the TinEye index.

Methods

Common parameters

Each search method (searchUrl and searchData) takes an optional parameter params that takes an associative array with any of these options:

<?php
$params = [
    'offset' => 0,
    'limit' => 10,
    'backlink_limit' => 100,
    'sort' => 'score',
    'order' => 'desc',
    'domain' => 'tineye.com',
];

For more information on possible settings please visit the TinEye API documention.

Search using an image URL

Use this method to have TinEye download an image URL and search it against the TinEye index.

<?php
/**
* Search for an image using an image URL
*
* @param String $url Image URL to be downloaded and searched
* @param Array $params Optional General Arguments
* @return Array Multidimensional Array of the returned JSON
*/

$tineyeapi = new tineye\api\TinEyeApi($api_private_key, $api_public_key);
$search_result = $tineyeapi->searchUrl('https://tineye.com/images/meloncat.jpg');

Search using image data

Use this method to upload an image to TinEye and search it against the TinEye index.

<?php
/**
* Search for an image using local image data
* TinEye supports JPEG, PNG, WEBP, GIF, BMP, or TIFF image formats
*
* @param String $image_data fopen stream of an image
* @param String $file_name Name of the file to be uploaded
* @param Array $params Optional General Arguments
*
* @return Array Multidimensional Array of the returned JSON
*/
$tineyeapi = new tineye\api\TinEyeApi($api_private_key, $api_public_key);
$search_result = $tineyeapi->searchData(
    fopen('./tests/meloncat.jpg', 'r'),
    'meloncat.jpg'
);

Get remaining searches

Use this method to get the number and status of remaining search bundles.

<?php
/**
* Returns information on search bundles 
* @return Array Multidimensional array of the returned JSON
*/
$tineyeapi = new tineye\api\TinEyeApi($api_private_key, $api_public_key);
$search_bundles = $tineyeapi->remainingSearches();

Get number of indexed images

Use this method to get the number and images currently indexed by TinEye

<?php
/**
* Returns the count of images in the TinEye index 
* @return Array Multidimensional array of the returned JSON
*/
$tineyeapi = new tineye\api\TinEyeApi($api_private_key, $api_public_key);
$search_bundles = $tineyeapi->imageCount();

Get the HTTP client

This method allows access to the wrapped GuzzleHttp client. More information is available at GuzzleHttp.

<?php
/**
* Returns the wrapped Guzzle client instance
* @return GuzzleHttp\Client
*/
$tineyeapi = new tineye\api\TinEyeApi($api_private_key, $api_public_key);
$guzzle_client = $tineyeapi->getClient();

Support

Please send comments, recommendations, and bug reports to [email protected].

Testing

Tests are located in the /tests folder and use PHPunit.

$ composer test

License

Licensed under the MIT License (MIT). Please see License File for more information.

tineye-api-php's People

Contributors

jgould22 avatar martinevong avatar andrei-dascalu avatar deslynx avatar rhettlunn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.