https://github.com/ezefranca/datamuse-swift
A datamuse api swift wrapper without dependencies
https://github.com/ezefranca/datamuse-swift
datamuse datamuse-api datamuse-swift ios macos swift
Last synced: about 1 year ago
JSON representation
A datamuse api swift wrapper without dependencies
- Host: GitHub
- URL: https://github.com/ezefranca/datamuse-swift
- Owner: ezefranca
- License: mit
- Created: 2017-11-11T13:47:10.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-12-19T10:14:12.000Z (over 1 year ago)
- Last Synced: 2025-06-17T14:02:28.747Z (about 1 year ago)
- Topics: datamuse, datamuse-api, datamuse-swift, ios, macos, swift
- Language: Swift
- Homepage:
- Size: 7.24 MB
- Stars: 24
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# datamuse-swift
[](https://cocoapods.org/pods/datamuse-swift)
[](https://raw.githubusercontent.com/ezefranca/datamuse-swift/master/LICENSE)
[](https://github.com/apple/swift-package-manager)
[](https://cocoapods.org/pods/datamuse-swift)
[](https://www.datamuse.com/api/)
A Datamuse API Swift wrapper without external depedencies and support for async/await.
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Methods](#methods)
- [License](#license)
## Requirements
- iOS 15+ / macOS 12+ / tvOS 15+ / watchOS 8+
- Xcode 15.0+
## Installation
### Swift Package Manager
To integrate `datamuse-swift` into your Xcode project, open your project settings, navigate to the "Package Dependencies" section, and add the following URL:
```
https://github.com/ezefranca/datamuse-swift.git
```
### CocoaPods
Add the following to your `Podfile`:
```ruby
platform :ios, '15.0'
use_frameworks!
pod 'datamuse-swift', '~> 1.0.0'
```
Run the following command to install the dependency:
```bash
$ pod install
```
### Manual Installation
Clone the repository and drag the `Sources` folder into your Xcode project.
## Usage
### Getting Started
First, import the library:
```swift
import datamuse_swift
```
Create an instance of `DataMuseClient`:
```swift
let client = DataMuseClient()
```
### Fetching Words
Use the `fetchWords` method with any of the predefined endpoints.
#### Example: Fetch Similar Words
```swift
Task {
do {
let words = try await client.fetchWords(endpoint: .similarWords(to: "ring"))
words.forEach { print($0.word) }
} catch {
print("Error: \(error.localizedDescription)")
}
}
```
## Methods
The following endpoints are available:
| Description | Method |
|---------------------------------------------------------------|----------------------------------------------------------------------------------------------|
| Words with a meaning similar to a given word | `.similarWords(to: String)` |
| Words related to a word that start with a specific letter | `.wordsRelated(to: String, startingWith: String)` |
| Words related to a word that end with a specific letter | `.wordsEndingWith(to: String, endingWith: String)` |
| Words spelled similarly to a given word | `.wordsSpelledLike(String)` |
| Words that rhyme with a given word | `.wordsThatRhyme(with: String)` |
| Words that rhyme with a given word and are related | `.wordsThatRhymeWithRelated(with: String, related: String)` |
| Adjectives often used to describe a word | `.adjectivesOftenUsed(toDescribe: String)` |
| Adjectives describing a word sorted by related topics | `.adjectivesDescribing(this: String, related: String)` |
| Nouns often described by a given adjective | `.nounsOftenDescribed(byAdjective: String)` |
| Words that often follow another word in a sentence | `.wordsThatFollow(following: String, startingWith: String)` |
| Words triggered by (strongly associated with) another word | `.wordsTriggered(by: String)` |
| Suggestions based on partial input | `.suggestions(for: String)` |
| Words that start, finish, and have a specific pattern | `.wordWithPattern(start: String, finish: String, lettersBetween: Int)` |
### Word Model
All API responses return an array of `Word` objects:
```swift
public struct Word: Codable {
public let word: String
public let score: Int?
}
```
## License
`datamuse-swift` is released under the MIT license. See [LICENSE](https://github.com/ezefranca/datamuse-swift/blob/master/LICENSE) for details.