SDKs overview
NLP Cloud offers a suite of Software Development Kits (SDKs) designed to facilitate integration with its natural language processing (NLP) API. These SDKs abstract the underlying HTTP requests and response parsing, allowing developers to interact with NLP Cloud's services using native language constructs. The available SDKs cover several popular programming languages, providing idiomatic interfaces for accessing features such as text generation, sentiment analysis, named entity recognition, and translation. The primary goal of these SDKs is to reduce the boilerplate code required for API interactions, enabling developers to focus on application logic rather than low-level API communication details.
Each SDK is typically maintained as an open-source project, often hosted on platforms like GitHub, allowing for community contributions and transparency. The SDKs are built to align with the NLP Cloud REST API specification, ensuring consistency in functionality across different language environments. This approach supports a broad developer base, from individual practitioners to enterprise teams, by providing familiar tools for integrating advanced NLP capabilities into various applications and workflows.
The SDKs handle common API interaction concerns, including authentication, request formatting, error handling, and response deserialization. This comprehensive approach simplifies the development process for applications that require integration with NLP Cloud's pre-trained or custom NLP models. Developers can find detailed instructions and code examples within the official NLP Cloud documentation, which covers setup, usage patterns, and specific examples for each supported language.
Official SDKs by language
NLP Cloud provides official SDKs for a range of programming languages, ensuring broad compatibility and ease of integration for developers. These SDKs are maintained by NLP Cloud and are designed to offer a consistent and reliable interface to the API. The following table outlines the official SDKs, their typical package names, installation commands, and maturity status. The maturity status generally reflects whether the SDK is actively maintained and recommended for production use.
| Language | Package Name | Installation Command | Maturity |
|---|---|---|---|
| Python | nlpcloud |
pip install nlpcloud |
Stable |
| Node.js | nlpcloud |
npm install nlpcloud |
Stable |
| Go | nlpcloud-go |
go get github.com/nlpcloud/nlpcloud-go |
Stable |
| Ruby | nlpcloud |
gem install nlpcloud |
Stable |
| .NET | NlpcloudClient |
Install-Package NlpcloudClient |
Stable |
| PHP | nlpcloud/nlpcloud |
composer require nlpcloud/nlpcloud |
Stable |
| Java | nlpcloud-java |
Maven/Gradle dependency | Stable |
These SDKs are continuously updated to reflect new API features and improvements. Developers are encouraged to refer to the specific SDK documentation pages for the latest version information and detailed usage instructions, including information on dependency management for Java and .NET projects.
Installation
Installing an NLP Cloud SDK typically involves using the package manager specific to the chosen programming language. The process is designed to be straightforward, allowing developers to quickly set up their environment and begin making API calls. Below are general installation instructions for the most commonly used SDKs.
Python
For Python, the SDK is available via PyPI. Ensure you have pip installed, which usually comes with Python distributions. Open your terminal or command prompt and run:
pip install nlpcloud
This command downloads and installs the latest version of the nlpcloud package and its dependencies. Developers can then import the library into their Python scripts.
Node.js
The Node.js SDK is published on npm. If you have Node.js and npm installed, navigate to your project directory in the terminal and execute:
npm install nlpcloud
This command adds the nlpcloud package to your project's node_modules directory and updates your package.json file. You can then require or import the module in your JavaScript/TypeScript files.
Go
For Go projects, the SDK can be fetched using the go get command. Ensure your Go environment is properly configured:
go get github.com/nlpcloud/nlpcloud-go
This command retrieves the SDK source code and makes it available for import within your Go modules. For more detailed Go module integration, consult the NLP Cloud Go SDK documentation.
Ruby
The Ruby SDK is available as a gem. Use the gem install command:
gem install nlpcloud
This will install the gem and its dependencies, making it available for use in your Ruby applications by requiring it.
.NET
For .NET applications, the SDK is distributed as a NuGet package. You can install it via the NuGet Package Manager Console in Visual Studio or using the .NET CLI:
Install-Package NlpcloudClient
or via .NET CLI:
dotnet add package NlpcloudClient
This adds a reference to the NlpcloudClient library in your C# or VB.NET project.
PHP
The PHP SDK is managed via Composer. If you have Composer installed, navigate to your project root and run:
composer require nlpcloud/nlpcloud
This command adds the NLP Cloud PHP client to your project's dependencies and generates the autoloader.
Java
For Java projects, the SDK is typically integrated using Maven or Gradle. You would add the appropriate dependency to your pom.xml (Maven) or build.gradle (Gradle) file. For example, a Maven dependency might look like this:
<dependency>
<groupId>com.nlpcloud</groupId>
<artifactId>nlpcloud-java</artifactId>
<version>1.0.0</version> <!-- Replace with the latest version -->
</dependency>
Refer to the NLP Cloud Java SDK documentation for the most current version and full dependency details.
Quickstart example
This quickstart example demonstrates how to perform sentiment analysis using the NLP Cloud Python SDK. Before running this code, ensure you have installed the Python SDK as described in the Installation section and obtained an API key from your NLP Cloud account.
Python Sentiment Analysis Example
This example initializes the client with an API key and then sends a text string for sentiment analysis. The response will contain the predicted sentiment (e.g., positive, neutral, negative) and associated scores.
import nlpcloud
# Replace 'YOUR_API_KEY' with your actual NLP Cloud API key
client = nlpcloud.Client("YOUR_API_KEY", gpu=False, lang="en")
text_to_analyze = "I am very happy with the service provided. It was excellent!"
try:
# Perform sentiment analysis
result = client.sentiment(text_to_analyze)
# Print the results
print(f"Text: {text_to_analyze}")
print(f"Sentiment: {result['scored_label']}")
print(f"Scores: {result['score']}")
except Exception as e:
print(f"An error occurred: {e}")
This snippet illustrates the basic pattern for interacting with the NLP Cloud API through its SDK: client initialization with an API key, calling a specific NLP function (sentiment in this case), and processing the returned JSON object. Similar patterns apply to other NLP tasks like text summarization or named entity recognition, with different method calls and parameters.
Community libraries
While NLP Cloud provides official SDKs for major programming languages, the open nature of its API also permits the development of community-contributed libraries and wrappers. These community efforts can sometimes offer alternative interfaces, additional utilities, or support for languages not officially covered by NLP Cloud. Developers often create these libraries to fit specific project requirements, integrate with particular frameworks, or experiment with different design patterns.
Community libraries are typically found on package managers (like PyPI, npm, RubyGems) or code hosting platforms (like GitHub). When considering a community-contributed library, it is advisable to evaluate its maintenance status, community support, and alignment with the Web API standards. Checking the project's repository for recent commits, open issues, and pull requests can provide insight into its activity level and reliability. Although NLP Cloud's official documentation primarily focuses on its first-party SDKs, the broader developer community may publish and maintain additional resources.
As of the current information, NLP Cloud emphasizes its official SDKs as the primary and recommended method for API integration. For any specific community-developed libraries, developers should consult community forums, package repositories, and direct project documentation to assess their suitability for production environments. The use of official SDKs is generally recommended for stability, ongoing support, and direct compatibility with the latest API features and updates, as detailed in the NLP Cloud developer documentation.