Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nftmaker_api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nftmaker_api

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

NftmakerApi

A Ruby client for the https://nft-maker.io/pro API.

It aims to support all API methods. The intuitive query methods allow to easily call the API endpoints.

Installation

Add this line to your application's Gemfile:

gem 'nftmaker_api'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install nftmaker_api

Configuration

The configuration options can be set by using the configure block

NftmakerApi.configure do |config|
  config.api_key = ENV.fetch('NFT_MAKER_PRO_API_KEY')
end

Alternatively, you can configure the settings by passing a hash of options to an instance like so

client = NftmakerApi.new api_key: "xyz",
                         http_adapter: :typheous

The following is the list of available configuration options

api_key      # The API key provided by nft-maker.io
http_adapter # The http client used for performing requests. Default :net_http
host         # The API endpoint. Default: https://api.nft-maker.io

1 Usage

To start using the gem, you first create a new client instance

client = NftmakerApi.new

and then you call the methods for the API endpoints.

1.1 Endpoints

List all projects

client.projects.list

Show metrics for a project

client.project(1634).metrics

List all NFTs for a project

client.project(1634).nfts.list     # all
client.project(1634).nfts.sold     # only sold
client.project(1634).nfts.free     # only free
client.project(1634).nfts.reserved # only reserved

Create a new project

client.projects.create(name: "Foo", policy_expires: true, policy_locks_at: Time.now.advance(months: 6), address_expires_in: 10)

Reserve NFT(s) from a project

client.project(1634).reservations.create(nft_count: 1, lovelace: 10_000000)              # Reserve a random NFT
client.project(1634).reservations.create(nft_id: 123, nft_count: 1, lovelace: 10_000000) # Reserve a specific NFT

Check / Cancel a reservation

client.project(1634).reservation("addr1...").check
client.project(1634).reservation("addr1...").cancel

2 Response Handling

Responses are wrapped into a NftmakerApi::Response object. The main reason is to allow direct access to the parsed JSON response body.

Sidenote: The JSON body is parsed using Oj which is a C implementation, hence much faster than JSON from Ruby's Standard Library.

client.projects.list.to_h
# => [{"id"=>123, "projectname" => "Foo", ...}, ...]

Access the original faraday response object

client.projects.list.original_response

2.1 Errors

Check if the request was successful or returned an error

client.projects.list.success?
client.projects.list.error?

Response errors are always NftmakerApi::Error objects.

client.projects.list.error

Show error message including status code, status phrase and the actual error message from the API

client.projects.list.error.full_message

Show status code

client.projects.list.error.status

Show error message returned from the API

client.projects.list.error.reason

3 Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/lacepool/nftmaker_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

4 License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 08 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc