Watson Developer Cloud Swift SDK
The Watson Developer Cloud Swift SDK is a collection of services to allow developers to quickly add Watson Cognitive Computing services and Analytics Insights for Weather to their Swift 3 applications.
The Watson Developer Cloud Swift SDK is currently in beta.
Table of Contents
- Installation
-
IBM Watson Services
- Alchemy Vision (partial)
- IBM Data and Analytics Services
- Authentication
- Building and Testing
- Open Source @ IBM
- License
- Contributing
Installation
The Watson Developer Cloud Swift SDK requires dependencies to run correctly. These dependencies can be found in the package manager file. You can downloading the needed dependencies by invoking package manager with "swift build" from terminal which creates the Packages directory. The project file can be created with "swift build -X" command invoked through terminal.
IBM Watson Services
Getting started with Watson Developer Cloud and Bluemix
The IBM Watson™ Developer Cloud (WDC) offers a variety of services for developing cognitive applications. Each Watson service provides a Representational State Transfer (REST) Application Programming Interface (API) for interacting with the service. Some services, such as the Speech to Text service, provide additional interfaces.
IBM Bluemix™ is the cloud platform in which you deploy applications that you develop with Watson Developer Cloud services. The Watson Developer Cloud documentation provides information for developing applications with Watson services in Bluemix. You can learn more about Bluemix from the following links:
The IBM Bluemix documentation, specifically the pages What is Bluemix? and the Bluemix overview. IBM developerWorks, specifically the IBM Bluemix section of IBM developerWorks and the article that provides An introduction to the application lifecycle on IBM Bluemix.
Alchemy Vision
AlchemyVision is an API that can analyze an image and return the objects, people, and text found within the image. AlchemyVision can enhance the way businesses make decisions by integrating image cognition.
Links
Requirements
- An Alchemy API Key
Usage
Instantiate an AlchemyVision object and set its api key
let alchemyVisionInstance = AlchemyVision(apiKey: String)
API calls are instance methods, and model class instances are returned as part of our callback.
e.g.
let failure = { (error: RestError) in print(error) }
alchemyVisionInstance.getRankedImageKeywords(url: urlString,
forceShowAll: true,
knowledgeGraph: true,
failure: failure) { (response) in
// code here
})
IBM Data and Analytics Services
Getting started with IBM Data and Analytics Services and Bluemix
Use IBM® Insights for Weather to incorporate weather data from The Weather Company (TWC) into your IBM® Bluemix® applications.
IBM Bluemix™ is the cloud platform in which you deploy applications that you develop with Watson Developer Cloud services. The Watson Developer Cloud documentation provides information for developing applications with Watson services in Bluemix. You can learn more about Bluemix from the following links:
The IBM Bluemix documentation, specifically the pages What is Bluemix? and the Bluemix overview. IBM developerWorks, specifically the IBM Bluemix section of IBM developerWorks and the article that provides An introduction to the application lifecycle on IBM Bluemix.
Insights for Weather
This service lets you integrate historical and real-time weather data from The Weather Company into your IBM Bluemix application. You can retrieve weather data for an area specified by a geolocation. The data allows you to forecast, detect, and visualize disruptive weather events that might affect decision making in your application.
You can add weather observations and forecasts to your Bluemix application and display the weather data for an area that is specified by a geolocation by using the Insights for Weather REST APIs. The Weather Company is the most comprehensive provider of historical and forecast weather data. Data for all forms of weather, including precipitation, barometric pressure, wind, and thunderstorms, is captured.
You can use the REST APIs to retrieve the following information:
An hourly weather forecast for the next 24 hours that starts from the current time for a specified geolocation. A daily weather forecast for the next 10 days that includes forecasts for the daytime and nighttime segments for a specified geolocation. This forecast includes the forecast narrative text string of up to 256 characters with appropriate units of measure for the location and in the language requested. The current observed weather data for a specified geolocation. This weather data includes temperature, precipitation, wind direction and speed, humidity, barometric pressure, dew point, visibility, and ultraviolet (UV) radiation. The observed weather data for a specified geolocation and a specified time range. This data is sourced from physical observation stations. This API returns weather observations for current conditions and past observations up to and including the previous 24 hours.
Links
Usage
Instantiate an Insights for Weather service:
let insightsForWeatherInstance = InsightsForWeather(username: username, password: password)
API calls are instance methods, and model class instances are returned as part of our callback.
e.g.
let failure = { (error: RestError) in print(error) }
insightsForWeather.getCurrentForecast(
units: units,
geocode: geocode,
language: language,
failure: failure) { response in
// code here
})
Authentication
IBM Watson Services and Insights for Weather are hosted in the Bluemix platform. Before you can use each service in the SDK, the service must first be created in Bluemix, bound to an Application, and you must have the credentials that Bluemix generates for that service. Alchemy services use a single API key, and all the other Watson services use a username and password credential.
Build + Test
XCode is used to build the project for testing and deployment. Select Product->Build For->Testing to build the project in XCode's menu.
In order to build the project and run the unit tests, a credentials.plist file needs to be populated with proper credentials in order to communicate with the running Watson services. A copy of this file is located in the project's folder under Tests. The credentials.plist file contains a key and value for each service's user name and password.
There are some tests already in place that can be displayed when selecting the Test Navigator in XCode. Right click on the test you want to run and select Test in the context menu to run that specific test. You can also select a full node and right-click to run all of the tests in that node or service.
Open Source @ IBM
Find more open source projects on the IBM Github Page
License
This library is licensed under Apache 2.0. Full license text is available in LICENSE.
This SDK is intended solely for use with an Apple iOS product and intended to be used in conjunction with officially licensed Apple development tools.
Contributing
See CONTRIBUTING on how to help out.