Coder Social home page Coder Social logo

contentstack-dotnet's Introduction

Contentstack

Contentstack dotnet

.NET SDK for Contentstack's Content Delivery API

Getting Started

This guide will help you get started with our .NET SDK to build apps powered by Contentstack.

SDK Installation and Setup

To use the .NET SDK, download it from here

Open the terminal and install the contentstack module via ‘Package Manager’ command

PM> Install-Package contentstack.csharp

And via ‘.Net CLI’

dotnet add package contentstack.csharp

To use the module in your application, you need to first Add Namespace to your class

using Contentstack.Core; // ContentstackClient 
using Contentstack.Core.Models; // Stack, Query, Entry, Asset, ContentType
using Contentstack.Core.Configuration; // ContentstackOptions

Initialize SDK

You will need to specify the API key, Access token, and Environment Name of your stack to initialize the SDK:

// Initialize the Contentstack 
ContentstackClient stack = new ContentstackClient("api_key", "access_token", "enviroment_name");

or:

//
var options = new ContentstackOptions()
{
    ApiKey = "<api_key>",
    AccessToken = "<access_token>"
    Environment = "<environment>"
}
ContentstackClient stack = new ContentstackClient(options);

Once you have initialized the SDK, you can start getting content in your app.

Basic Queries

Get a Single Entry

To retrieve a single entry from a content type, use the code snippet given below:

Entry entry = client.ContentType("blog").Entry("blta464e9fbd048668c");
entry.Fetch().ContinueWith((t) => { 
    if (!t.IsFaulted) { 
        Console.WriteLine("entry:" + t.Result);  
    } 
});

Get Multiple Entries

To retrieve multiple entries of a particular content type, use the code snippet given below:

Query query = client.ContentType("blog").Query(); 
query.Where("title", "welcome"); 
query.IncludeSchema(); 
query.IncludeCount(); 
query.ToJSON(); 
query.Find().ContinueWith((t) => { 
    if (!t.IsFaulted) { 
         Entry[] result = t.Result.Result; 
         Console.WriteLine("result" + result); 
    } 
});

These were example of some of the basic queries of the SDK. For advanced queries, refer to our API reference documentation by visiting the link given below.

API Reference

Go through our .NET SDK API Reference guide to know about the methods that can be used to query your content in Contentstack.

Read .NET API Reference Guide

Example

To help you get started, we have created a sample application that is powered by Contentstack .NET SDK. Click on the link below to read the tutorial of the app.

.NET News Console App

Helpful Links

contentstack-dotnet's People

Contributors

uttamukkoji avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.