{ "info": { "author": "shakee93, jesusperiago, jakesherman", "author_email": "jake@jakesherman.com", "bugtrack_url": null, "classifiers": [], "description": "# fonoapi - Python wrapper around Fono Api\n\nhttps://fonoapi.freshpixl.com/\n\nThe Fono Api is an API which can provide **mobile device descriptions** such as model, brand, cpu, gpu, dimensions, release date, and more. This package package provides a convenient wrapper around the Fono Api via the `requests` package.\n\nThe [API](https://github.com/shakee93/fonoapi) was developed [shakee93](https://github.com/shakee93). This package started off as a fork of a [package](https://github.com/jesusperiago/fonoapi) written by [jesusperiago](https://github.com/jesusperiago) - I added the `getlatest` method to take advantage of the [getlatest API method](https://fonoapi.freshpixl.com/v1/getlatest), and made a lot of under-the-hood organizational changes in order to submit this package to `PyPI` to make it more easily available.\n\n### Installation\n\n```bash\npip install fonoapi\n```\n\n## Tutorial\n\nBefore starting, make sure to [generate an API token](https://fonoapi.freshpixl.com/token/generate#). We are going to start by creating a `FonoAPI` object, which we initialize with our API token in order to start interacting with the Fono Api:\n\n```python\nfrom fonoapi import FonoAPI\nfon = FonoAPI('TOKEN')\n```\n\n### Getting devices matching a specific device name\n\nImagine we have a specific device in mind, say the **iPhone 7**, that we wish to learn more about. We can use the `getdevice` method to return information from the API about this specific device:\n\n```python\ndevice = 'iPhone 7'\niPhone_7 = fon.getdevice(device)\nprint(iPhone_7)\n```\n\n | Devices Object: mobile device data|\n ------------------------------------\n Number of devices : 4\n Input parameters : {'device': 'iPhone 7', 'position': None, 'brand': None}\n\nThe `getdevice` method returns a `Devices` object, an object that makes it easy to retrieve data from the Fono Api. Printing out the object gives us information on how many devices we retrieved information for, and what parameters were passed to `getdevice`.\n\nWe can output the data in the `Devices` object in three ways by calling the following methods on the `Devices` object:\n- `dataframe` : As a Pandas DataFrame, where each row corresponds to a phone\n- `list_of_dicts` : As a list of dictionaries, with one dict per phone\n- `list_of_lists : `As a list of lists, where each sublist corresponds to a phone\n\nNot all mobile devices in the Fono Api have every possible attribute associated with them. In the case of `list_of_dicts`, only the attributes associated with each phone is included in each phone's dictionary. In the cases of `dataframe` or `list_of_lists`, you may choose specific columns to include for every phone (if you don't specify columns to include, all possible columns are included). In this case, devices with no value for a particular column will have values of `numpy.nan` or `None`, respectively.\n\nIn our case, let's look at the attributes `Brand, DeviceName, body_c` for the devices returned by our API call:\n\n```python\nprint(iPhone_7.dataframe(['Brand', 'DeviceName', 'body_c']))\n```\n\nBrand | DeviceName | body_c |\n| --- | --- | --- |\n| Prestigio | Prestigio MultiPhone 7500 | None |\n| Prestigio | Prestigio MultiPhone 7600 Duo | None |\n| Apple | Apple iPhone 7 Plus | - IP67 certified - dust and water resistant\\r\\... |\n| Apple | Apple iPhone 7 | - IP67 certified - dust and water resistant\\r\\... |\n\n- There are two non-Apple devices by Prestigio in the list! The model names of the two devices begin with Prestigio Mult**iPhone 7**500, so it's understandable that they would show up when we searched for the string 'iPhone 7'\n- The two Prestigio devices don't have a value for the `body_c` attribute, so they have `NaN` values for that column\n\nIn order to get rid of the Prestigio devices in our results, all we have to do is specify the `brand` argument to the `getdevice` method:\n\n```python\ndevice, brand = 'iPhone 7', 'Apple'\niPhone_7 = (\n fon\n .getdevice(device, brand)\n .dataframe(['Brand', 'DeviceName', 'body_c'])\n)\nprint(iPhone_7)\n```\n\nBrand | DeviceName | body_c |\n| --- | --- | --- |\n| Apple | Apple iPhone 7 Plus | - IP67 certified - dust and water resistant\\r\\... |\n| Apple | Apple iPhone 7 | - IP67 certified - dust and water resistant\\r\\... |\n\n### Getting the latest devices for a specific brand\n\n`getlatest` will return information about the most recent devices for a given brand. For example, let's imagine that we wish to get data on the lastest mobile devices from Apple:\n\n```python\nbrand = 'Apple'\nlatest_apples = (\n fon\n .getlatest(brand, limit=5)\n .dataframe(['DeviceName', 'announced', '_3_5mm_jack_', 'talk_time'])\n)\nprint(latest_apples)\n```\n\nDeviceName | announced | _3_5mm_jack_ | talk_time |\n| --- | --- | --- | --- |\n| Apple iPad Pro 12.9 | 2017, June | Yes | Up to 10 h (multimedia) |\n| Apple iPad Pro 10.5 | 2017, June | Yes | Up to 10 h (multimedia) |\n| Apple iPad 9.7 | 2017, March | Yes | Up to 10 h (multimedia) |\n| Apple iPhone 8 | Not announced yet | No | None |\n| Apple Watch Series 1 Sport 42mm | 2016, September | No | Up to 3 h 40 min |\n\nFinally, perhaps we want to retrieve data on the most recent mobile devices for a whole host of brands ... but we're not sure if we spelled the brand names correctly. By default, when `getlatest` (or `getdevice`) don't retrieve any results from the API, they return an empty `Devices` object. That empty `Devices` object has a value of `True` for its `null` class attribute (and a value of `False` for its `not_null` class attribute). For example:\n\n```python\nbrands = ['Apple', 'Samsung', 'LG', 'Huawei', 'SonyEricsson']\nbrand_devices = []\nfor brand in brands:\n devices = fon.getlatest(brand, limit=3)\n brand_devices.append(devices)\n```\n\n Could not retrieve brand information for brand SonyEricsson from the Fono API.\n\n\n```python\n# Print out the Devices object for SonyEricsson\nprint(brand_devices[-1])\n```\n\n | Devices Object: mobile device data|\n ------------------------------------\n Number of devices : 0\n Input parameters : {'brand': 'SonyEricsson', 'limit': 3}\n\nThe problem here is that there is no brand SonyEricsson in the API, the correct name would have been just Ericsson. Let's say that we want to take all of the device information that we stored in `brand_devices`, a list of `Devices` object, and create a single Pandas DataFrame:\n\n```python\nimport pandas as pd\ncolumns = ['Brand', 'DeviceName', 'announced', 'talk_time']\nbrand_devices = [devices.dataframe(columns) for devices\n in brand_devices if devices.not_null]\nall_brands = pd.concat(brand_devices)\nprint(all_brands)\n```\n\nBrand | DeviceName | announced | talk_time |\n| --- | --- | --- | --- |\n| Apple | Apple iPad Pro 12.9 | 2017, June | Up to 10 h (multimedia) |\n| Apple | Apple iPad Pro 10.5 | 2017, June | Up to 10 h (multimedia) |\n| Apple | Apple iPad 9.7 | 2017, March | Up to 10 h (multimedia) |\n| Samsung | Samsung Galaxy Tab A 8.0 (2017) | Not announced yet | NaN |\n| Samsung | Samsung Galaxy C10 | Not announced yet | NaN |\n| Samsung | Samsung Galaxy J5 (2017) | 2017, June | Up to 21 h (3G) |\n| LG | LG V30 | Not announced yet | NaN |\n| LG | LG X venture | 2017, May | Up to 24 h (3G) |\n| LG | LG Stylo 3 Plus | 2017, May | Up to 14 h (3G) |\n| Huawei | Huawei MediaPad M3 Lite 8 | 2017, June | NaN |\n| Huawei | Huawei Honor 9 | 2017, June | NaN |\n| Huawei | Huawei nova 2 plus | 2017, May | NaN |\n\n## Tests\n\nPass a valid API token to `py.test` to run the package's unit tests.\n\n```bash\npy.test --apitoken \n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/jakesherman/fonoapi/archive/v0.1.4.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jakesherman/fonoapi", "keywords": "api,mobile,phone,FonoApi", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "fonoapi", "package_url": "https://pypi.org/project/fonoapi/", "platform": "", "project_url": "https://pypi.org/project/fonoapi/", "project_urls": { "Download": "https://github.com/jakesherman/fonoapi/archive/v0.1.4.tar.gz", "Homepage": "https://github.com/jakesherman/fonoapi" }, "release_url": "https://pypi.org/project/fonoapi/0.1.4/", "requires_dist": [ "numpy (>=1.10)", "pandas (>=0.20.0)", "pytest (>=3.1.0)", "requests (>=2.18.0)" ], "requires_python": "", "summary": "Access Freshpixl's Fono Api to gain insight into mobile phones", "version": "0.1.4" }, "last_serial": 5945191, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "77e9d6de13c02279ca0005985b071edb", "sha256": "c6ebc7d37d2f4185a119dd25557b653bd9110d598da9805cd114cd22693fc78b" }, "downloads": -1, "filename": "fonoapi-0.1.0.tar.gz", "has_sig": false, "md5_digest": "77e9d6de13c02279ca0005985b071edb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10097, "upload_time": "2017-07-25T15:21:16", "url": "https://files.pythonhosted.org/packages/32/81/b5c55459c979bc36c0a87e5f7b14f79b5aa4dff16aeedfda50eaabf1b94b/fonoapi-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "4de434c7f81b3bbbe4069ea44be2443b", "sha256": "3c5a7d0ab1ee6660fd9806e01c5496a1f63b50f934ad7d823c916a1e860450aa" }, "downloads": -1, "filename": "fonoapi-0.1.1.tar.gz", "has_sig": false, "md5_digest": "4de434c7f81b3bbbe4069ea44be2443b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10088, "upload_time": "2017-07-25T16:09:24", "url": "https://files.pythonhosted.org/packages/82/ac/5ad9b8c9eb6feea8988a3cafd81182253b2360bea583b76059bfd2c2303e/fonoapi-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "9b730e7ea7df192f0f3445c56fc6afe1", "sha256": "676d59fc1f9700869ac54c769b7fd53c9b64ec635c1286b574b26bd3ebe68dea" }, "downloads": -1, "filename": "fonoapi-0.1.2.tar.gz", "has_sig": false, "md5_digest": "9b730e7ea7df192f0f3445c56fc6afe1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10230, "upload_time": "2017-07-25T18:28:31", "url": "https://files.pythonhosted.org/packages/be/01/adc463bc55f045cea5e9825f154c8fb6944fe0da66b9e9781d3acf6a4a48/fonoapi-0.1.2.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "f2d1d1d999401f976715ae9767651b1f", "sha256": "ebc62d30acc1ea6e81f5e27a7f74f1b8aea1dae7ef21ee46ad45efa25ca40271" }, "downloads": -1, "filename": "fonoapi-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "f2d1d1d999401f976715ae9767651b1f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9608, "upload_time": "2019-10-08T14:49:35", "url": "https://files.pythonhosted.org/packages/2c/c9/c55a97e29400ed60f7eacfe56f978ecc04ade8e480fde8d0421eb411e5fa/fonoapi-0.1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1b9f6319efc6354e4210fa69af2be6e3", "sha256": "84e8ea3c337faa6408684f26650da8fe870394c2d353489097d02a716dbc211d" }, "downloads": -1, "filename": "fonoapi-0.1.4.tar.gz", "has_sig": false, "md5_digest": "1b9f6319efc6354e4210fa69af2be6e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11491, "upload_time": "2019-10-08T14:49:38", "url": "https://files.pythonhosted.org/packages/d4/3f/5d6f616edae595b2d077076e342be63b450bf9f80f33e626c877256c7115/fonoapi-0.1.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f2d1d1d999401f976715ae9767651b1f", "sha256": "ebc62d30acc1ea6e81f5e27a7f74f1b8aea1dae7ef21ee46ad45efa25ca40271" }, "downloads": -1, "filename": "fonoapi-0.1.4-py3-none-any.whl", "has_sig": false, "md5_digest": "f2d1d1d999401f976715ae9767651b1f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9608, "upload_time": "2019-10-08T14:49:35", "url": "https://files.pythonhosted.org/packages/2c/c9/c55a97e29400ed60f7eacfe56f978ecc04ade8e480fde8d0421eb411e5fa/fonoapi-0.1.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "1b9f6319efc6354e4210fa69af2be6e3", "sha256": "84e8ea3c337faa6408684f26650da8fe870394c2d353489097d02a716dbc211d" }, "downloads": -1, "filename": "fonoapi-0.1.4.tar.gz", "has_sig": false, "md5_digest": "1b9f6319efc6354e4210fa69af2be6e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11491, "upload_time": "2019-10-08T14:49:38", "url": "https://files.pythonhosted.org/packages/d4/3f/5d6f616edae595b2d077076e342be63b450bf9f80f33e626c877256c7115/fonoapi-0.1.4.tar.gz" } ] }