You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
ThePlug API Integration Package provides an intuitive and secureinterface to interact with the Plug API. It enables developers to storeuser credentials securely, fetch data using custom SQL queries, andmanage authentication tokens automatically.
Note: To access the Plug API, you must have valid credentials(username and password) provided by the API administrators.
Note: Plug uses Microsoft SQL as its database system, so SQLqueries must adhere to Microsoft SQL Server syntax (e.g.,SELECT TOP 1 instead ofLIMIT).
Installation
You can install the development version of the package directly fromGitHub:
# Install devtools if not already installedinstall.packages("devtools")# Install the packagedevtools::install_github("StrategicProjects/plug")
Features
Secure Credential Storage: Safely store and retrieve usercredentials with keyring.
Token Management: Automatically handle API token generation andexpiration.
Query Execution: Execute custom SQL queries securely using thePlug API.
Data Download: Retrieve all data from specific tables with ease.
Getting Started
Before using the package, you need to store your Plug API credentialssecurely:
# Store your username and passwordplug_store_credentials("your_username","your_password")
Fetching a Token
The package automatically fetches and caches an authentication token. Ifyou need to retrieve it manually, use:
# Fetch a valid tokentoken<- plug_get_valid_token()
Listing Stored Credentials and Tokens
You can list stored credentials and tokens:
# List credentialscredentials<- plug_list_credentials()print(credentials)# List tokenstokens<- plug_list_tokens()print(tokens)
Executing SQL Queries
ou can execute custom SQL queries on the Plug API:
# Example: Execute a querydata<- plug_execute_query(sql_template="SELECT * FROM Contratos_VIEW LIMIT 1")
# Example: Download All Data from a Tabledata<- plug_download_base(base_name="Contratos_VIEW")print(data)
Development
This package is under active development. Contributions are welcome! Ifyou encounter any issues, please open an issue on GitHub.