lexisnexisapi


Namelexisnexisapi JSON
Version 3.0.3.13 PyPI version JSON
download
home_pagehttps://pypi.org/project/lexisnexisapi/
Summarya module to support lexisnexis api(s)
upload_time2024-02-15 18:49:40
maintainer
docs_urlNone
authorRobert Cuffney
requires_python
licenseMIT
keywords metabase webservices lexisnexis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Metabase.py Documentation

## 1. Introduction

### Overview

The `metabase.py` module provides a Python interface to interact with the Metabase API. It allows you to perform searches and retrieve articles using the Metabase API. The module facilitates the creation of Python objects representing the API response, making it easy to work with the data.

### Authors

- Robert Cuffney
- Ozgur Aycan
- CS Integration Consultants @ LexisNexis

### Version

Current version: 3.0.3.12
## 2. Installation

### Dependencies

To use the `metabase.py` module, you need the following dependencies:

- requests
- json
- pandas
- datetime
- lexisnexisapi

### Installation

You can install the required dependencies using pip:

```bash
pip install requests pandas lexisnexisapi
```

## 3. Usage

### Importing the Module

To use the `metabase.py` module in your Python script, import it as follows:

```python
from lexisnexisapi import metabase
```

### Search Class

The `Search` class is the main interface to perform searches and retrieve articles from Metabase. It has the following attributes and methods:

#### Attributes:

- `parameters`: A dictionary of Metabase search parameters.
- `articles`: A list containing the articles retrieved from the Metabase API response.
- `totalResults`: The total number of articles available in the search results.

#### Methods:

- `__init__(self, full_dataset=False, **kwargs)`: Initializes the Search object and performs the API request. If `full_dataset` is set to `True`, it retrieves all available articles by making multiple API calls.
- `articles_dataframe(self, *args)`: Returns a Pandas DataFrame containing the articles' data. You can pass a list of desired fields (`*args`) to filter the DataFrame.
- `create_file(self, file='articles.json')`: Creates a JSON file with the articles retrieved from the search.
- `set_parameters(self, p)`: Sets the Metabase search parameters based on the input dictionary `p`.

### Streamline Class

The `Streamline` class helps maximize Metabase search calls without exceeding the rate limit. It keeps track of the remaining API calls per minute and waits for a new minute if needed.

#### Attributes:

- `key`: Metabase API key.
- `start_minute`: The starting minute when the Streamline object is instantiated.
- `minute_limit`: The maximum number of API calls allowed per minute based on the rate limit.
- `calls_remaining`: The remaining API calls within the current minute.

#### Methods:

- `__init__(self, key)`: Initializes the Streamline object with the Metabase API key and fetches the rate limit information.
- `track_calls(self)`: Updates the remaining API calls and waits for a new minute if the limit is reached.
- `restart(self)`: Restarts the Streamline object.
- `wait_for_new_min(self)`: Pauses execution until a new minute starts.
- `get_current_minute(self)`: Returns the current minute as an integer.

### Article Class

The `Article` class represents an instance of a single article retrieved from Metabase. It sets each key from the article dictionary as an attribute of the class.

### Helper Functions

The module also provides some helper functions:

- `http_request(p)`: Performs an HTTP request to the Metabase API with the given parameters `p` and returns the API response as a dictionary.
- `rate_check(mbkey)`: Calls the Metabase rate limit API and returns the results as a list of dictionaries.
- `set_Metabase_Search_Key(v)`: Sets the Metabase search key in the credentials.
- `get_time()`: Returns the current minute as an integer.

## 4. Examples

### Basic Search Example

```python
from lexisnexisapi import metabase

# Set the Metabase search key (optional, you can set it in the parameters directly)
metabase.set_mb_search_key("your_metabase_key")

# Perform a basic search
search = metabase.Search(query="your_query_here", limit=100)

# Get the DataFrame of articles
df = search.articles_dataframe("title", "author", "published_date")
print(df.head())
```

### Full Dataset Search Example

```python
from lexisnexisapi import metabase

# Set the Metabase search key (optional, you can set it in the parameters directly)
metabase.set_mb_search_key("your_metabase_key")

# Perform a full dataset search
search = metabase.Search(full_dataset=True, query="your_query_here")

# Create a JSON file with all the articles
search.create_file("articles_full.json")
```

### Article Instance Example

```python
from lexisnexisapi  import metabase

# Set the Metabase search key (optional, you can set it in the parameters directly)
metabase.set_mb_search_key("your_metabase_key")

# Perform a search and get an article instance
search = metabase.Search(query="your_query_here", limit=1)
article_instance = metabase.Article(search.articles[0])

# Access attributes of the article instance
print(article_instance.title)
print(article_instance.author)
print(article_instance.published_date)
```

### Index Terms Example

```python
from lexisnexisapi import metabase

# Set the Metabase search key (optional, you can set it in the parameters directly)
metabase.set_mb_search_key("your_metabase_key")

# Perform a search
search = metabase.Search(query="your_query_here", limit=100)

# Get the DataFrame of index terms
index_terms_df = metabase.indexTerms(search, "economy", "politics", "technology")
print(index_terms_df.head())
```

Please note that you should replace `your_metabase_key` and `your_query_here` with your actual Metabase API key and desired search query, respectively, in the examples.

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.org/project/lexisnexisapi/",
    "name": "lexisnexisapi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "metabase webservices lexisnexis",
    "author": "Robert Cuffney",
    "author_email": "Robert Cuffney <robert.cuffney@lexisnexis.com>",
    "download_url": "https://files.pythonhosted.org/packages/3a/b0/8abcfbc220978589ae36c2942a6873b8e969e6421a3702be76816991b7a2/lexisnexisapi-3.0.3.13.tar.gz",
    "platform": null,
    "description": "# Metabase.py Documentation\n\n## 1. Introduction\n\n### Overview\n\nThe `metabase.py` module provides a Python interface to interact with the Metabase API. It allows you to perform searches and retrieve articles using the Metabase API. The module facilitates the creation of Python objects representing the API response, making it easy to work with the data.\n\n### Authors\n\n- Robert Cuffney\n- Ozgur Aycan\n- CS Integration Consultants @ LexisNexis\n\n### Version\n\nCurrent version: 3.0.3.12\n## 2. Installation\n\n### Dependencies\n\nTo use the `metabase.py` module, you need the following dependencies:\n\n- requests\n- json\n- pandas\n- datetime\n- lexisnexisapi\n\n### Installation\n\nYou can install the required dependencies using pip:\n\n```bash\npip install requests pandas lexisnexisapi\n```\n\n## 3. Usage\n\n### Importing the Module\n\nTo use the `metabase.py` module in your Python script, import it as follows:\n\n```python\nfrom lexisnexisapi import metabase\n```\n\n### Search Class\n\nThe `Search` class is the main interface to perform searches and retrieve articles from Metabase. It has the following attributes and methods:\n\n#### Attributes:\n\n- `parameters`: A dictionary of Metabase search parameters.\n- `articles`: A list containing the articles retrieved from the Metabase API response.\n- `totalResults`: The total number of articles available in the search results.\n\n#### Methods:\n\n- `__init__(self, full_dataset=False, **kwargs)`: Initializes the Search object and performs the API request. If `full_dataset` is set to `True`, it retrieves all available articles by making multiple API calls.\n- `articles_dataframe(self, *args)`: Returns a Pandas DataFrame containing the articles' data. You can pass a list of desired fields (`*args`) to filter the DataFrame.\n- `create_file(self, file='articles.json')`: Creates a JSON file with the articles retrieved from the search.\n- `set_parameters(self, p)`: Sets the Metabase search parameters based on the input dictionary `p`.\n\n### Streamline Class\n\nThe `Streamline` class helps maximize Metabase search calls without exceeding the rate limit. It keeps track of the remaining API calls per minute and waits for a new minute if needed.\n\n#### Attributes:\n\n- `key`: Metabase API key.\n- `start_minute`: The starting minute when the Streamline object is instantiated.\n- `minute_limit`: The maximum number of API calls allowed per minute based on the rate limit.\n- `calls_remaining`: The remaining API calls within the current minute.\n\n#### Methods:\n\n- `__init__(self, key)`: Initializes the Streamline object with the Metabase API key and fetches the rate limit information.\n- `track_calls(self)`: Updates the remaining API calls and waits for a new minute if the limit is reached.\n- `restart(self)`: Restarts the Streamline object.\n- `wait_for_new_min(self)`: Pauses execution until a new minute starts.\n- `get_current_minute(self)`: Returns the current minute as an integer.\n\n### Article Class\n\nThe `Article` class represents an instance of a single article retrieved from Metabase. It sets each key from the article dictionary as an attribute of the class.\n\n### Helper Functions\n\nThe module also provides some helper functions:\n\n- `http_request(p)`: Performs an HTTP request to the Metabase API with the given parameters `p` and returns the API response as a dictionary.\n- `rate_check(mbkey)`: Calls the Metabase rate limit API and returns the results as a list of dictionaries.\n- `set_Metabase_Search_Key(v)`: Sets the Metabase search key in the credentials.\n- `get_time()`: Returns the current minute as an integer.\n\n## 4. Examples\n\n### Basic Search Example\n\n```python\nfrom lexisnexisapi import metabase\n\n# Set the Metabase search key (optional, you can set it in the parameters directly)\nmetabase.set_mb_search_key(\"your_metabase_key\")\n\n# Perform a basic search\nsearch = metabase.Search(query=\"your_query_here\", limit=100)\n\n# Get the DataFrame of articles\ndf = search.articles_dataframe(\"title\", \"author\", \"published_date\")\nprint(df.head())\n```\n\n### Full Dataset Search Example\n\n```python\nfrom lexisnexisapi import metabase\n\n# Set the Metabase search key (optional, you can set it in the parameters directly)\nmetabase.set_mb_search_key(\"your_metabase_key\")\n\n# Perform a full dataset search\nsearch = metabase.Search(full_dataset=True, query=\"your_query_here\")\n\n# Create a JSON file with all the articles\nsearch.create_file(\"articles_full.json\")\n```\n\n### Article Instance Example\n\n```python\nfrom lexisnexisapi  import metabase\n\n# Set the Metabase search key (optional, you can set it in the parameters directly)\nmetabase.set_mb_search_key(\"your_metabase_key\")\n\n# Perform a search and get an article instance\nsearch = metabase.Search(query=\"your_query_here\", limit=1)\narticle_instance = metabase.Article(search.articles[0])\n\n# Access attributes of the article instance\nprint(article_instance.title)\nprint(article_instance.author)\nprint(article_instance.published_date)\n```\n\n### Index Terms Example\n\n```python\nfrom lexisnexisapi import metabase\n\n# Set the Metabase search key (optional, you can set it in the parameters directly)\nmetabase.set_mb_search_key(\"your_metabase_key\")\n\n# Perform a search\nsearch = metabase.Search(query=\"your_query_here\", limit=100)\n\n# Get the DataFrame of index terms\nindex_terms_df = metabase.indexTerms(search, \"economy\", \"politics\", \"technology\")\nprint(index_terms_df.head())\n```\n\nPlease note that you should replace `your_metabase_key` and `your_query_here` with your actual Metabase API key and desired search query, respectively, in the examples.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "a module to support lexisnexis api(s)",
    "version": "3.0.3.13",
    "project_urls": {
        "Homepage": "https://pypi.org/project/lexisnexisapi/"
    },
    "split_keywords": [
        "metabase",
        "webservices",
        "lexisnexis"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8d309c2a43fb75667291ffd269e56081cab351d7c7ca82277b84755760a73c73",
                "md5": "2fe36339b84bac35fc7739aa812f18e2",
                "sha256": "d1b8a83902e0004b80235824fa6aea01429b9ccf20e66bed6e36a0060d8af0f2"
            },
            "downloads": -1,
            "filename": "lexisnexisapi-3.0.3.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2fe36339b84bac35fc7739aa812f18e2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9795,
            "upload_time": "2024-02-15T18:49:39",
            "upload_time_iso_8601": "2024-02-15T18:49:39.146133Z",
            "url": "https://files.pythonhosted.org/packages/8d/30/9c2a43fb75667291ffd269e56081cab351d7c7ca82277b84755760a73c73/lexisnexisapi-3.0.3.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ab08abcfbc220978589ae36c2942a6873b8e969e6421a3702be76816991b7a2",
                "md5": "f838b2650130acce01b88da7f3f50ff0",
                "sha256": "6b8ba21481b39f99858858652465cb4045e3affda7dff03a0770bfe3e365f2aa"
            },
            "downloads": -1,
            "filename": "lexisnexisapi-3.0.3.13.tar.gz",
            "has_sig": false,
            "md5_digest": "f838b2650130acce01b88da7f3f50ff0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10437,
            "upload_time": "2024-02-15T18:49:40",
            "upload_time_iso_8601": "2024-02-15T18:49:40.366919Z",
            "url": "https://files.pythonhosted.org/packages/3a/b0/8abcfbc220978589ae36c2942a6873b8e969e6421a3702be76816991b7a2/lexisnexisapi-3.0.3.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-15 18:49:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "lexisnexisapi"
}
        
Elapsed time: 0.29817s