<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0">

<channel>
	<title>Rest Api Example</title>
	<atom:link href="http://www.restapiexample.com/feed/" rel="self" type="application/rss+xml"/>
	<link>https://www.restapiexample.com/</link>
	<description>Rest api tutorials</description>
	<lastBuildDate>Fri, 05 Jul 2024 15:06:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.restapiexample.com/wp-content/uploads/2016/12/cropped-R-rest-32x32.png</url>
	<title>Rest Api Example</title>
	<link>https://www.restapiexample.com/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<itunes:explicit>no</itunes:explicit><itunes:subtitle>Rest api tutorials</itunes:subtitle><item>
		<title>Golang Switch Case with Example</title>
		<link>https://www.restapiexample.com/golang-tutorial/golang-switch-case-with-example/</link>
		
		<dc:creator><![CDATA[RestAPIExample Team]]></dc:creator>
		<pubDate>Sat, 09 Dec 2023 06:57:26 +0000</pubDate>
				<category><![CDATA[golang tutorial]]></category>
		<guid isPermaLink="false">https://www.golanglearn.com/?p=296</guid>

					<description><![CDATA[<p>In this post, we will see here how we can use the switch statement in the Golang. This allows you to conduct various actions in Golang based on various situations. If/else logic can also be expressed with a switch without an expression. Golang also has a switch() statement, similar to those seen in other programming [&#8230;]</p>
<p>The post <a href="https://www.restapiexample.com/golang-tutorial/golang-switch-case-with-example/">Golang Switch Case with Example</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>In this post, we will see here how we can use the <strong>switch statement in the Golang</strong>. This allows you to conduct various actions in Golang based on various situations. If/else logic can also be expressed with a switch without an expression.</p>



<span id="more-1292"></span>



<p>Golang also has a <strong>switch()</strong> statement, similar to those seen in other programming languages like PHP and Java.</p>



<p>The Golang switch statement is a way to write multiple <strong>if-else</strong> statements and is used to execute one of several code blocks based on the value of an expression.</p>



<p>The switch statement allows you to test multiple values of an expression and execute different code blocks depending on the result.</p>



<p><strong>The Syntax:</strong></p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">switch expression {
    case exp1: statement1
    case exp2: statement2
    case exp3: statement3
    ...
    default: statement4
}</pre>



<p>Commas can be used to separate multiple expressions in the same case statement. We may also declare a default case, which will be used if <strong>none</strong> of the other cases match.</p>



<p>Go language supports two types of switch statements:</p>



<ul class="wp-block-list">
<li><strong>Expression Switch</strong>: This switch statement is used to select one of many blocks of code to be executed based on the expression&#8217;s value.</li>



<li><strong>Type Switch</strong>: A type switch compares types instead of values. It will be compared to the type in the switch expression.</li>
</ul>



<h2 class="wp-block-heading">Simple Example Using Switch Expression</h2>



<p>The below example is using a switch expression.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">package main
import "fmt"
import "time"
func main() {
	switch time.Now().Weekday() {
		case time.Saturday, time.Sunday:
			fmt.Println("It's the weekend")
		default:
			fmt.Println("It's a weekday")
	}
}</pre>



<p><strong>Output:</strong></p>



<pre class="wp-block-preformatted">It's a weekday</pre>



<h2 class="wp-block-heading">Simple Example Using Switch Type</h2>



<p>In the expression of the type-switch block, only interfaces can be used. The switch statement in Golang can also be used to test multiple values in a single case. </p>



<p>Let&#8217;s see the below example for the <strong>switch</strong> type:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">package main
import "fmt"

func main() {
	var value interface{}
	switch q:= value.(type) {
		case bool:
		fmt.Println("value is of boolean type")
		case float64, float32:
		fmt.Println("value is of float type")
		case int:
		fmt.Println("value is of int type")
		default:
		fmt.Printf("value is of type: %T", q)
	}
}</pre>



<p>In this example, the value of <code>type</code> is set to int, and the switch statement is used to test the value of <strong>type</strong>. The case <code>float64, float32</code> tests for multiple values and will execute the code block if the value of type is either <code>float64</code> or <code>float</code>32. In this case, since the value of type is int, the code block for case <code>int</code> will be executed, and the message &#8220;value is of int type&#8221; will be printed to the console.</p>



<p><strong>Output:</strong></p>



<pre class="wp-block-preformatted">value is of int type</pre>



<h2 class="wp-block-heading">Switch Statement With Expression</h2>



<p>You can also use expressions in the switch statement in Golang. For example:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">package main

import "fmt"

func main() {
  age := 34
  switch {
  case age &lt; 18:
    fmt.Println("younger")
  case age > 18:
    fmt.Println("older than 18")
  default:
    fmt.Println("age is not valid")
 }
}</pre>



<h2 class="wp-block-heading">Conclusion</h2>



<p>We have learned the basic usage of <strong>&#8220;switch&#8221;</strong> statement with examples. You can create simplifies complex decision-making using switch statement. We are comparing a variable against multiple alternatives using switch statement.</p>
<p>The post <a href="https://www.restapiexample.com/golang-tutorial/golang-switch-case-with-example/">Golang Switch Case with Example</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How to Generate Random Number Slice in Golang</title>
		<link>https://www.restapiexample.com/golang-tutorial/how-to-generate-random-number-slice-in-golang/</link>
		
		<dc:creator><![CDATA[RestAPIExample Team]]></dc:creator>
		<pubDate>Tue, 04 Apr 2023 11:52:46 +0000</pubDate>
				<category><![CDATA[golang tutorial]]></category>
		<guid isPermaLink="false">https://www.golanglearn.com/?p=391</guid>

					<description><![CDATA[<p>This tutorial lets you know, How to generate a random number using Golang slices. I will use a time package to generate a random number and store them into slices using the UNIX timestamp. We&#8217;ll disscuss many scenarios to generate random numbers.You can use generate random number in you golang application based on needs. The [&#8230;]</p>
<p>The post <a href="https://www.restapiexample.com/golang-tutorial/how-to-generate-random-number-slice-in-golang/">How to Generate Random Number Slice in Golang</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This tutorial lets you know, How to generate a random number using Golang slices. I will use a time package to generate a random number and store them into slices using the UNIX timestamp.</p>



<span id="more-1318"></span>



<p>We&#8217;ll disscuss many scenarios to generate random numbers.You can use  generate random number in you golang application based on needs.</p>



<p>The golang provides <strong>math/rand</strong> package to genrate random number.</p>



<h2 class="wp-block-heading">Common Scenario to Generate Random Numbers</h2>



<ul class="wp-block-list">
<li><strong>Seeding Number:</strong> Sometimes, We need to seed some numbers against a column for a database table or sample data.</li>



<li><strong>Cryptographically Secure Randomness:</strong> Use the <code>crypto/rand</code> package to generate secure random numbers if your application needs cryptographic security.</li>



<li><strong>Range Number:</strong> We can also generate random numbers within a specific range.</li>
</ul>



<h2 class="wp-block-heading">Random Number Slicing</h2>



<p>Let&#8217;s explore different scenarios with example to generate random numbers in golang application. Random numbers play a crucial role in gaming and to cryptographic algorithms.</p>



<h3 class="wp-block-heading">How to Generate Random Number Slice Using Unix Timestamp</h3>



<p> Let&#8217;s creates methods that ll generate a slice of 20 number, Which have some values that are negative and some that are positive.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">(
	"fmt"
	"math/rand"
    "time"
    )

func generateRandomSlice(size int) []int {
 
    slice := make([]int, size, size)
    rand.Seed(time.Now().UnixNano())
    for i := 0; i &lt; size; i++ {
        slice[i] = rand.Intn(999) - rand.Intn(999)
    }
    return slice
}
slice := generateRandomSlice(20)
fmt.Println("\n--- The Random Slices of 20 Number ---\n\n", slice, "\n")</pre>



<p>I have imported <code>math/rand</code>,time package to generate UNIX timestamp. Both methods are identically the same but different with respect to values, the first method will return both type values, negative and positive integer but the second method will return only positive numbers.</p>



<h3 class="wp-block-heading">How to Generate Positive Random Number</h3>



<p>The below method will generate a slice of 10 number, Which have only a positive number.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">(
	"fmt"
	"math/rand"
    "time"
    )

func generateRandomNumber(size int) []int {
 	rand_number := make([]int, size, size)
 	for i := 0; i &lt; size; i++ {
        rand_number[i] = rand.Intn(100)
    }
    
    return rand_number
}
rand_number := generateRandomNumber(10)
	fmt.Println("\n--- The Random Number of 10 Length ---\n\n", rand_number, "\n")</pre>



<h3 class="wp-block-heading">Floating-Point Random Numbers</h3>



<p>We can also generate a slice of random floating-point numbers:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">package main

import (
	"fmt"
	"math/rand"
	"time"
)

func generateRandomFloatSlice(length int, min, max float64) []float64 {
	rand.Seed(time.Now().UnixNano())

	randomFloatSlice := make([]float64, length)

	for i := 0; i &lt; length; i++ {
		randomFloatSlice[i] = rand.Float64()*(max-min) + min
	}

	return randomFloatSlice
}

func main() {
	randomFloatSlice := generateRandomFloatSlice(5, 1.0, 5.0)

	fmt.Println("Random Float Slice:", randomFloatSlice)
}
</pre>



<h3 class="wp-block-heading">Random Password Generation</h3>



<p>A common technique for creating secure passwords is to use randomness. Let&#8217;s write a programme to produce a password at random:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">package main

import (
	"fmt"
	"math/rand"
	"time"
)

const (
	lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
	uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	digits           = "0123456789"
	specialChars     = "!@#$%^&amp;*()-_=+[]{}|;:'\",.&lt;>/?"
)

func generatePassword(length int) string {
	rand.Seed(time.Now().UnixNano())

	allChars := lowercaseLetters + uppercaseLetters + digits + specialChars
	password := make([]byte, length)

	for i := 0; i &lt; length; i++ {
		password[i] = allChars[rand.Intn(len(allChars))]
	}

	return string(password)
}

func main() {
	randomPassword := generatePassword(12)
	fmt.Println("Random Password:", randomPassword)
}</pre>



<p>In the above code, I have created a <code>generatePassword()</code> function that is used to create randomly password by using a pool of lowercase, uppercase, numbers, and special characters.</p>
<p>The post <a href="https://www.restapiexample.com/golang-tutorial/how-to-generate-random-number-slice-in-golang/">How to Generate Random Number Slice in Golang</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Golang MVC Project Structure without Any Framework</title>
		<link>https://www.restapiexample.com/golang-tutorial/golang-mvc-project-structure-without-any-framework/</link>
		
		<dc:creator><![CDATA[RestAPIExample Team]]></dc:creator>
		<pubDate>Sat, 11 Feb 2023 10:14:59 +0000</pubDate>
				<category><![CDATA[golang tutorial]]></category>
		<guid isPermaLink="false">https://www.golanglearn.com/?p=401</guid>

					<description><![CDATA[<p>This Golang tutorial help to create MVC architecture for your golang project. There are a lot of go frameworks available that follow MVC architecture, but here we will create MVC based go project without any Golang framework, We will use core Golang to create structure. We will create the rest endpoint that will print messages [&#8230;]</p>
<p>The post <a href="https://www.restapiexample.com/golang-tutorial/golang-mvc-project-structure-without-any-framework/">Golang MVC Project Structure without Any Framework</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This Golang tutorial help to create MVC architecture for your golang project. There are a lot of go frameworks available that follow MVC architecture, but here we will create MVC based go project without any Golang framework, We will use core Golang to create structure.</p>



<span id="more-1317"></span>



<p>We will create the rest endpoint that will print messages based on the MVC structure go code. We will use <code>http</code> for client and server communication, <code>MUX</code> for routing, <strong>MUX package</strong> is the powerful URL router and dispatcher.</p>



<h2 class="wp-block-heading">What MVC Pattern</h2>



<p>The Model-View-Controller (MVC) pattern is a popular design pattern for building web applications.</p>



<p>There are three main components: the model, the view, and the controller. In a Go (Golang) project, you can structure your MVC as follows:</p>



<ol class="wp-block-list">
<li><strong>Model</strong>: This component represents the data and business logic of the application. It handles the storage, retrieval, and manipulation of data. In Go, the model can be represented by structs and other data types.</li>



<li><strong>View</strong>: This component is responsible for presenting the data to the user. In Go, the view can be implemented using templates or other presentation libraries.</li>



<li><strong>Controller</strong>: This component acts as an intermediary between the model and the view. It receives user input, updates the model accordingly, and decides which view to display. In Go, the controller can be implemented using functions and methods.</li>
</ol>



<p>Here&#8217;s an example of how you can structure a basic MVC project in Go:</p>



<ul class="wp-block-list">
<li><strong>app/controllers</strong>:</li>
</ul>



<p>This folder contains all controller classes and is added to the controller package.</p>



<ul class="wp-block-list">
<li><strong>app/models</strong>:</li>
</ul>



<p>This folder contains all <strong>interfaces</strong>, and <strong>structs</strong> and is added to the <strong>models</strong> package.</p>



<ul class="wp-block-list">
<li><strong>app/route</strong>:</li>
</ul>



<p>This folder contains the route file and is added to the route package.</p>



<ul class="wp-block-list">
<li><strong>app/helpers</strong>:</li>
</ul>



<p>This folder contains the helper class, and constant class, and is added to the helper package.</p>



<ul class="wp-block-list">
<li><strong>config/.env</strong>:</li>
</ul>



<p>This folder contains a configuration file, like we will add a <code>.env</code> file for the environment parameters of golang project.</p>



<p>Finally, the <code>main.go</code> file is the entry point for the application, where you&#8217;ll configure routes, start the server and initialize dependencies.</p>



<h2 class="wp-block-heading">Using Golang MVC for REST API development</h2>



<p>We will create a go project under <strong>gopath</strong> working directory, We will create a <code>mvc_example</code> project and main.go file it into this folder.</p>



<p>We will create a config folder under a <code>mvc_example/app/</code> folder. We will create a <code>.env</code> file that has a <strong>key-value</strong> pair of the environment variables. We will access that file using <strong>joho/godotenv</strong> package. We will add the below key/value pair for the test:</p>



<p><code>site : "restapiexample.com"</code></p>



<p>Load the <code>.env</code> file into the main function and access the env variable using key <code>'site'</code>, which will return <strong>&#8216;restapiexample.com&#8217;</strong>.</p>



<p>Created Models folder under <code>mvc_example/app/</code> folder and created <code>types.go</code> file. We will add the below code into <code>types.go</code> file:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">package models

type User struct {
   Data struct {
      ID        int    `json:"id"`
      FirstName string `json:"first_name"`
      LastName  string `json:"last_name"`
      Avatar    string `json:"avatar"`
   } `json:"data"`
}</pre>



<p>We have created a User type struct that will contain an array of user data.</p>



<p>Created Route folder under <code>mvc_example/app/</code> folder.Added <code>route.go</code> file into this folder. We will add below code to <code>route.go</code> file:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">package route

import (
   "github.com/gorilla/mux"
   "mvc_example/app/controllers"
)
func GetRoutes() *mux.Router {
    routes := mux.NewRouter().StrictSlash(false)

    routes := routes.PathPrefix("/api/v1/").Subrouter()

    routes.HandleFunc("/hello", controllers.Hello).Methods("GET")

    return routes;
}</pre>



<p>Let&#8217;s create the controller&#8217;s folder into <code>mvc_example/app/</code> folder. We will add the below code into <code>home.go</code> file:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">package controllers

import (
   "fmt"
   "net/http"
   "github.com/gorilla/mux"
   "mvc_example/app/models"
   "encoding/json"
   log "github.com/sirupsen/logrus"
)
func Hello(w http.ResponseWriter, r *http.Request) {
   fmt.Println("Hello, I am home controller!")
   w.WriteHeader(http.StatusOK)
   fmt.Fprintf(w, "Hello, I am home controller!")
}</pre>



<p>Created <code>main.go</code> file under <code>mvc_example/app/</code> folder. We will add the below code into <code>main.go</code> file:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">package main

import (
   "github.com/joho/godotenv"
   log "github.com/sirupsen/logrus"
   "os"
   "mvc_example/app/route"
   "net/http"
)

func main() {
   log.Info("Applicatio has been started on : 8080")
   err := godotenv.Load('/config')
   if err != nil {
    log.Fatal("Error loading .env file")
   }

   key := os.Getenv("Site")
   log.Info(key)

   //creating instance of mux
   routes := route.GetRoutes()
   http.Handle("/", routes)
   log.Fatal(http.ListenAndServe(":8080", nil))
}</pre>



<p>We have imported <strong>godotenv</strong> package to access <code>.env</code> file variable, if the file is not loaded successfully, then you will get a fatal error in the console. We have access a site variable using <code>os.Getenv()</code> method.</p>



<p>Also used route package to access routing functionality and handle all routes using <code>GetRoutes()</code> method.</p>



<p>We are running the server on the <strong>8080</strong> port, if this port has already taken other applications then you will get a fatal error.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>I have created a simple MVC folder structure and created simple <strong>GET</strong> type rest call, You can access rest call using <code>'http://localhost:8080/api/v1/hello'</code>.</p>
<p>The post <a href="https://www.restapiexample.com/golang-tutorial/golang-mvc-project-structure-without-any-framework/">Golang MVC Project Structure without Any Framework</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How To Upload a File Attachment Using Service Now API</title>
		<link>https://www.restapiexample.com/php-tutorials/how-to-upload-a-file-attachment-using-service-now-api/</link>
		
		<dc:creator><![CDATA[RestAPIExample Team]]></dc:creator>
		<pubDate>Mon, 17 Oct 2022 15:26:31 +0000</pubDate>
				<category><![CDATA[php tutorials]]></category>
		<guid isPermaLink="false">https://www.restapiexample.com/?p=1157</guid>

					<description><![CDATA[<p>This tutorial help to upload attachment into service-now using API. I am using service now attachment API to upload file into the existing SCR request. I am taking laravel API sample to demonstrate upload functionality, You can convert this PHP source code into any other language, You can take reference from here and implement it [&#8230;]</p>
<p>The post <a href="https://www.restapiexample.com/php-tutorials/how-to-upload-a-file-attachment-using-service-now-api/">How To Upload a File Attachment Using Service Now API</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This tutorial help to <strong>upload attachment into service-now using API</strong>. I am using service now attachment API to upload file into the existing SCR request.</p>



<span id="more-1157"></span>



<p>I am taking laravel API sample to demonstrate upload functionality, You can convert this PHP source code into any other language, You can take reference from here and implement it into your preferred language.</p>



<p>The <a class="link-red" href="https://developer.servicenow.com/dev.do#!/reference/api/rome/rest/c_AttachmentAPI" rel="nofollow">Attachment API</a> allows you to upload and query file attachments. You can upload or retrieve a single file with each request.</p>



<h2 class="wp-block-heading">Add a file Attachment in Using Service Now API</h2>



<p>Let&#8217;s create a file <code>TestController.php</code> into Http/Controller/ folder, which ll have all code to upload a file.</p>



<p><strong>Step 1:</strong> Created an API endpoint into the <code data-enlighter-language="generic" class="EnlighterJSRAW">routes/api.php</code> file.</p>



<p><code data-enlighter-language="generic" class="EnlighterJSRAW">$api-&gt;post('/add_attachment/{scr}', 'App\Http\Controllers\TestController@uploadScrFile');</code></p>



<p><strong>Step 2:</strong> Created a client into the service file, I have created a client method into the <code data-enlighter-language="generic" class="EnlighterJSRAW">testController.php</code> file.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">private function _client($content_type) {
     $base64 = base64_encode(getenv('USER').":".getenv('PASS'));
     $endpoint = getenv('API_URL');
     $client = new Client([
          'base_uri' => $endpoint,
          'timeout' => 300.0,
          'headers' => ['Content-Type' => $content_type, 'Authorization' => "Basic " . $base64],
          'http_errors' => false,
          'verify' => false
      ]);
     return $client;
}</pre>



<p><strong>Step 3:</strong> Created a method that will use to upload a file into service now.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function uploadScrFile($scrNum, $file) {
  $content_type = $file->getMimeType();
  $file_name = $file->getClientOriginalName();
  return array('content_type' => $content_type, 'file_name' => $file_name);
  //echo '&lt;pre/>';print_r($file_name);die;
   $scrRes = $this->findScrByName($scrNum);
   $sysid = head($scrRes['results'])['sys_id']['value'];

   $client = $this->_client($content_type);
   \Log::info("Attach File in SCR");
  try {
     \Log::info("SCR number:", array("SCR" => $scrNum));
     $response = $client->post("attachment/file?table_name=test&amp;table_sys_id=$sysid&amp;file_name=$file_name", ['body' => fopen($file->getRealPath(), "r")]);
     $response = json_decode($response->getBody(), true);
     return ['results' => $response['result']];
   } catch (\Exception $ex) {
     throw new BadRequestException('bad_req', $ex->getMessage());
   }
}</pre>



<p><strong>Step 4:</strong> Finally, Create a controller method that will call the service method to upload a file.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function uploadScrFile(Request $request, $scr) {
  $file = $request->files->get('file');      
  return $this->response->array((array) $this->uploadScrFile($scr, $file));
}</pre>
<p>The post <a href="https://www.restapiexample.com/php-tutorials/how-to-upload-a-file-attachment-using-service-now-api/">How To Upload a File Attachment Using Service Now API</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Simple Bubble Sort with Time Complexity In Golang</title>
		<link>https://www.restapiexample.com/golang-tutorial/simple-bubble-sort-with-time-complexity-in-golang/</link>
					<comments>https://www.restapiexample.com/golang-tutorial/simple-bubble-sort-with-time-complexity-in-golang/#comments</comments>
		
		<dc:creator/>
		<pubDate>Mon, 17 Oct 2022 03:15:55 +0000</pubDate>
				<category><![CDATA[golang tutorial]]></category>
		<guid isPermaLink="false">https://www.golanglearn.com/?p=403</guid>

					<description><![CDATA[<p>This tutorial helps to create bubble sort in golang, The bubble sort help to sort the elements using the comparison between the current node with the immediate next node, based on condition. The element will swap according to the requirement and goes down to the last element one by one. At the end of the [&#8230;]</p>
<p>The post <a href="https://www.restapiexample.com/golang-tutorial/simple-bubble-sort-with-time-complexity-in-golang/">Simple Bubble Sort with Time Complexity In Golang</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This tutorial helps to create bubble sort in golang, The bubble sort help to sort the elements using the comparison between the current node with the immediate next node, based on condition.</p>



<span id="more-1316"></span>



<p>The element will swap according to the requirement and goes down to the last element one by one. At the end of the first phase, the last element has maximized the element of the list.<br></p>



<p>The Bubble sort follows the following rule:</p>



<ul class="wp-block-list"><li><strong>Step 1:</strong> Start from the left-hand side of the array</li><li><strong>Step 2:</strong> Compare the first two numbers of 0 and 1 index</li><li><strong>Step 3:</strong> If <code>a[0] &gt; a[1]</code> than swap both number positions. And if <code>a[0] &lt; a[1]</code> than do now swap and compare the next two numbers i.e. <code>a[1] and a[2]</code>.</li><li><strong>Step 4:</strong> Step-3 process repeats until there are no more numbers left to compare.</li></ul>



<p>The time complexity is <code>Ω(n)</code> and worst is <code>O(n^2)</code>.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">package main

import (
	"fmt"
	_ "os"
)

func main() {
	a := []int{31, 8, 6, 54, 95, 84, 71, 67}
	fmt.Printf("%v\n", a)

	len_arr := len(a) - 1
	fmt.Printf("The length of array : %v\n", len_arr)

	for i := 0; i &lt; len_arr; i++ {
		for j := 0; j &lt; len_arr-i; j++ {
			fmt.Printf("first index:%v The value : %v\n", a[j], a[j+1])
			if a[j] > a[j+1] {
				tmp := a[j]
				a[j] = a[j+1]
				a[j+1] = tmp

			}
		}
		fmt.Println("Iteration=======================", i+1)

		fmt.Printf("\nYour sort Array : %v\n", a)

	}

	fmt.Printf("Your sort Array : %v", a)
}</pre>
<p>The post <a href="https://www.restapiexample.com/golang-tutorial/simple-bubble-sort-with-time-complexity-in-golang/">Simple Bubble Sort with Time Complexity In Golang</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.restapiexample.com/golang-tutorial/simple-bubble-sort-with-time-complexity-in-golang/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>How To Read and Save a File Using Gitlab API</title>
		<link>https://www.restapiexample.com/php-tutorials/how-to-read-and-save-a-file-using-gitlab-api/</link>
		
		<dc:creator><![CDATA[RestAPIExample Team]]></dc:creator>
		<pubDate>Thu, 04 Aug 2022 02:59:08 +0000</pubDate>
				<category><![CDATA[php tutorials]]></category>
		<guid isPermaLink="false">https://www.restapiexample.com/?p=1154</guid>

					<description><![CDATA[<p>This tutorial help to save a file using GitLab v4 API. I have already shared a tutorial that helps to read a file from gitlab repository. We&#8217;ll save that file GitLab repo using GitLab API. Sometimes, We need to read a file from GitLab repo, and modify and save it into GitLab repo. Repository files [&#8230;]</p>
<p>The post <a href="https://www.restapiexample.com/php-tutorials/how-to-read-and-save-a-file-using-gitlab-api/">How To Read and Save a File Using Gitlab API</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This tutorial help to save a file using GitLab v4 API. I have already shared a tutorial that helps to <a href="https://www.restapiexample.com/php-tutorials/how-to-read-file-from-gitlab-using-api/" class="link-red" title="read file from gitlab">read a file from gitlab</a> repository.</p>



<span id="more-1154"></span>



<p>We&#8217;ll save that file GitLab repo using GitLab API. Sometimes, We need to read a file from GitLab repo, and modify and save it into GitLab repo.</p>



<p><a href="https://docs.gitlab.com/ee/api/repository_files.html">Repository files API</a> helps to fetch, create, update, and delete files in from your repository. </p>



<h2 class="wp-block-heading">Update Existing File in the Repository</h2>



<p> This allows you to update a single file. For updating multiple files with a single request, This is a protected api.</p>



<p><strong>The Syntax:</strong></p>



<p><code data-enlighter-language="generic" class="EnlighterJSRAW">PUT /projects/:id/repository/files/:file_path</code></p>



<h2 class="wp-block-heading">Update a file Using Gitlab V4 API</h2>



<p>I am using laravel 8 to create an API and expose an endpoint to update a file into Gitlab.</p>



<p>Let&#8217;s create a <code data-enlighter-language="generic" class="EnlighterJSRAW">TestController.php</code> file into <strong>Http/Controller</strong> folder.</p>



<p>First, we&#8217;ll create a connect method that&#8217;ll connect laravel application with gitlab v4 API.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">private function _client() {

      $token = env('GITLAB_TOKEN');
      $client = new Client([
         'base_uri' => env("GITLAB_URL"),
         'timeout' => 300,
      'headers' => ['Content-Type' => 'application/json', "Accept" => "application/json", "PRIVATE-TOKEN" => $token],
         'http_errors' => false,
         'verify' => false
      ]);
      return $client;
 }</pre>



<p>Let&#8217;s create an endpoint that ll use to update file from gitlab.</p>



<p><code data-enlighter-language="generic" class="EnlighterJSRAW">Route::post('save_gitlab_file_content',&nbsp;'TestController@saveGitlabFileContent');</code></p>



<p>Create above method into the controller file:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function saveGitlabFileContent(request $request) {
   $parameters = $request->json()->all();
   if(empty($parameters['project_id'])) {    
	  return $this->jsonpError('project id is empty', 400, 400);   
   }
   if(empty($parameters['file_path'])) { 
     return $this->jsonpError('file_path is empty', 400, 400); 
  }
   $resp = $this->updateFileInRepo($parameters['project_id'], $parameters['file_path'], $parameters['payloads']);
   return $this->jsonpSuccess($resp);  
}</pre>



<p>Let&#8217;s define the service method to connect with gitlab api and save the file.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function updateFileInRepo($project_id, $filename, $payload) {
      $client = $this->_client($this->gitlabAPI); 
      $response = $client->put("projects/$project_id/repository/files/$filename", ['json' => $payload])->getBody()->getContents();   
      
      return json_decode($response); 
}</pre>
<p>The post <a href="https://www.restapiexample.com/php-tutorials/how-to-read-and-save-a-file-using-gitlab-api/">How To Read and Save a File Using Gitlab API</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How To Read File From Gitlab Using API</title>
		<link>https://www.restapiexample.com/php-tutorials/how-to-read-file-from-gitlab-using-api/</link>
		
		<dc:creator><![CDATA[RestAPIExample Team]]></dc:creator>
		<pubDate>Thu, 04 Aug 2022 02:44:30 +0000</pubDate>
				<category><![CDATA[php tutorials]]></category>
		<guid isPermaLink="false">https://www.restapiexample.com/?p=1147</guid>

					<description><![CDATA[<p>This tutorial help to read a file from GitLab using API. I am creating a rest API that reads data from GitLab project and returns it in text format data. Sometimes, we need to read a file from the GitLab repo and modify it, I&#8217;ll share a separate tutorial to save a file into GitLab [&#8230;]</p>
<p>The post <a href="https://www.restapiexample.com/php-tutorials/how-to-read-file-from-gitlab-using-api/">How To Read File From Gitlab Using API</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This tutorial help to <strong>read a file from GitLab using API</strong>. I am creating a rest API that reads data from GitLab project and returns it in text format data.</p>



<span id="more-1147"></span>



<p>Sometimes, we need to read a file from the GitLab repo and modify it, I&#8217;ll share a separate tutorial to save a file into GitLab repo using API.</p>



<p>Repository files API helps to fetch, create, update, and delete files from your repository.</p>



<h2 class="wp-block-heading">Get the file from a repository</h2>



<p>The get file API help to receive information about a file in the repository like name, size, and content. File content is <strong>Base64</strong> encoded.</p>



<p>This endpoint can be accessed without authentication if the repository is publicly accessible.</p>



<p><strong>The Syntax:</strong></p>



<p><code>GET /projects/:id/repository/files/:file_path</code></p>



<h2 class="wp-block-heading">Read a file from Gitlab Using V4 API</h2>



<p>I am using laravel 8 to create an API and expose an endpoint to read files from Gitlab. Let&#8217;s create a TestController.php file in <strong>Http/Controller</strong> folder.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">private function _client() {

      $token = env('GITLAB_TOKEN');
      $client = new Client([
         'base_uri' => env("GITLAB_URL"),
         'timeout' => 300,
      'headers' => ['Content-Type' => 'application/json', "Accept" => "application/json", "PRIVATE-TOKEN" => $token],
         'http_errors' => false,
         'verify' => false
      ]);
      return $client;
}</pre>



<p>First, we&#8217;ll create a connect method that&#8217;ll connect laravel application with GitLab v4 API.</p>



<p>Let&#8217;s create an endpoint that ll use to read files from GitLab.</p>



<p><code data-enlighter-language="generic" class="EnlighterJSRAW">Route::post('read_gitlab_file_content',&nbsp;'TestController@getGitlabFileContent');</code></p>



<p>Create the above method into the controller file:</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function getGitlabFileContent(request $request) { 
  $parameters = $request->json()->all();
  if(empty($parameters['project_id'])) { 
     return $this->jsonpError('project id is empty', 400, 400);   
  }
  if(empty($parameters['file_path'])) {   
  return $this->jsonpError('file_path is empty', 400, 400);   
  }
  $resp = $this->getFileInRepo($parameters['project_id'], $parameters['file_path']);

  return $this->jsonpSuccess($resp);  
}</pre>



<p>Let&#8217;s define a service method to connect with gitlab API and read files.</p>



<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">public function getFileInRepo($project_id, $filename) {  
    $client = $this->_client();     
    $response = $client->get("projects/$project_id/repository/files/$filename/raw")->getBody()->getContents();       
    return $response;  
}</pre>
<p>The post <a href="https://www.restapiexample.com/php-tutorials/how-to-read-file-from-gitlab-using-api/">How To Read File From Gitlab Using API</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Top 7 Use Cases For WYSIWYG editors</title>
		<link>https://www.restapiexample.com/build-rest-api/top-7-use-cases-for-wysiwyg-editors/</link>
		
		<dc:creator><![CDATA[RestAPIExample Team]]></dc:creator>
		<pubDate>Sat, 11 Jun 2022 05:09:10 +0000</pubDate>
				<category><![CDATA[Rest API Example]]></category>
		<guid isPermaLink="false">https://www.restapiexample.com/?p=1067</guid>

					<description><![CDATA[<p>Ever wondered why you would need a WYSIWYG Editor? You’d be surprised at how much you can do with these editors and the use cases that come along with them. Many of these use cases, we’re sure you’ll be amazed that it can be done effortlessly. 1. CMS Content Management Systems need content. Here is [&#8230;]</p>
<p>The post <a href="https://www.restapiexample.com/build-rest-api/top-7-use-cases-for-wysiwyg-editors/">Top 7 Use Cases For WYSIWYG editors</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Ever wondered why you would need a WYSIWYG Editor? You’d be surprised at how much you can do with these editors and the use cases that come along with them. Many of these use cases, we’re sure you’ll be amazed that it can be done effortlessly.</p>



<span id="more-1067"></span>



<h2 class="wp-block-heading">1. CMS</h2>



<p>Content Management Systems need content. Here is where WYSIWYG editors come in, you can use editors to make sure that your content is what you envision them to be. Format your content with what you want, create proper hierarchy with markdown support on most <a href="https://froala.com/wysiwyg-editor/" class="link-red">HTML editors</a>.</p>



<h2 class="wp-block-heading">2. Portfolios</h2>



<p>If you are a freelancer, developer, or anyone that needs an online presence, editors like this are just for you. You can focus on designing your content and making yourself stand out apart from the rest of the competition.</p>



<h2 class="wp-block-heading">3. Code Snippets</h2>



<p>Ever wondered how these cool looking code snippets are made?</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh5.googleusercontent.com/3ehb1zUbO_ht6Wbh9GcyP7-dPYazCIDQCc07ITiE-DQZJYZJxZTAVkFB6LcQMoxvYYMkfdvnoh2nm4IkyRD-Mst7kYEjYbwOytwHq8XuEvfV7LW_T8Am1H86VTQHSaCCe_6pQEWIHXDzlH5XQw" alt=""/></figure>



<p>Well with wysiwyg editors, you can style code snippets the way you want and embed them within your website.</p>



<h2 class="wp-block-heading">4. Blogs</h2>



<p>For blogs, it&#8217;s best if you focus on your content instead of how to code it. With WYSIWYG Editors, you can definitely create your blog and never have to worry about the code behind it.</p>



<h2 class="wp-block-heading">5. Knowledge Bases</h2>



<p>If you want to build a knowledge base for your team, proper formatting is necessary. WYSIWYG editors give you that kind of formatting without having to think about html code. With how easy it is to use editors nowadays, you&#8217;ll be able to create beautiful knowledge bases in no time</p>



<h2 class="wp-block-heading">6. Mobile Apps</h2>



<p>You can remove the hassle of creating forms inside your Mobile Application when you use HTML editors. Developing in mobile is hard, you don’t need to make it harder by just using ready made solutions by <a class="link-red" href="https://froala.com/blog/general/7-recommended-tools-to-build-wysiwyg-solutions/" rel="nofollow">reputable companies</a>.</p>



<h2 class="wp-block-heading">7. Note Taking Applications</h2>



<p>Creating Note Taking applications is easy. But you can take it to the next level with wysiwyg editors. Some even have markdown support</p>



<p>In conclusion, there are a lot of use cases in which WYSIWYG editors come in handy. They are low code, meaning you won’t have to do anything aside from <a href="https://froala.com/wysiwyg-editor/docs/overview/" rel="nofollow" class="link-red">installing it and plugging it</a> into your application.</p>
<p>The post <a href="https://www.restapiexample.com/build-rest-api/top-7-use-cases-for-wysiwyg-editors/">Top 7 Use Cases For WYSIWYG editors</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Five AI Models for Data Extraction That You Need to Consider for Your Business</title>
		<link>https://www.restapiexample.com/misc/five-ai-models-for-data-extraction-that-you-need-to-consider-for-your-business/</link>
		
		<dc:creator><![CDATA[RestAPIExample Team]]></dc:creator>
		<pubDate>Thu, 19 May 2022 19:03:34 +0000</pubDate>
				<category><![CDATA[Misc]]></category>
		<guid isPermaLink="false">http://www.restapiexample.com/?p=1060</guid>

					<description><![CDATA[<p>Source The impact of automated data extraction Companies collect and use data from multiple sources to strategize, build corporate plans, and do everything that can keep them at the top of their game. However, most of the data is unstructured, leading to the wastage of potentially helpful information. But if you consider gathering data, it [&#8230;]</p>
<p>The post <a href="https://www.restapiexample.com/misc/five-ai-models-for-data-extraction-that-you-need-to-consider-for-your-business/">Five AI Models for Data Extraction That You Need to Consider for Your Business</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-image"><img decoding="async" src="https://lh3.googleusercontent.com/FdexLvj2ObgEaIJtAdPiqGDOGfuM9M2FRAz_LcqW5pWL7S_WjjkpRMw-7HoMRzv8AXrH80eshEsi2TuOaWKo4Xt0-qWzjMzUXEBNrli6gXeAARZpZXEu_6DK2SKj6vWdOtwTvOFKNPHQUOAx_g" alt=""/></figure>



<p class="credit"><a href="https://healthitanalytics.com/news/machine-learning-automates-data-extraction-for-predictive-analytics" rel="noopener noreferrer"><em>Source</em></a></p>



<h2 class="wp-block-heading"><strong>The impact of automated data extraction</strong></h2>



<p>Companies collect and use data from multiple sources to strategize, build corporate plans, and do everything that can keep them at the top of their game. However, most of the data is unstructured, leading to the wastage of potentially helpful information. But if you consider gathering data, it will take a lot of time to analyze the same information.&nbsp;</p>



<span id="more-1060"></span>



<p>Enter automated data extraction. This data collection method can help you transform unstructured data into valuable data. By understanding machine learning for business, you can make the right choices for your company. An AI—powered data extraction method can bring numerous benefits to your organization.&nbsp;</p>



<h2 class="wp-block-heading"><strong>What do you need to know about automated data extraction?</strong></h2>



<figure class="wp-block-image"><img decoding="async" src="https://lh5.googleusercontent.com/QCG8NdZeAH1iJ4ivgQxaqSgxX-DIuKK7Qnzh9P6H4OJJKPwCnei-UVzuKkpjbvx2RaPy6OpkKuWwa5PRpStho0IgDYffuABSeRCAX5ifj6I62OOiBUD_cmsi06aq-zT_5zQQiIBbK4sa-APmRQ" alt="ai model"/></figure>



<p><a href="https://levity.ai/blog/what-is-data-extraction" rel="noopener noreferrer"><em>Source</em></a></p>



<ol class="wp-block-list"><li><strong>Automated data extraction is a more efficient method for large amounts of data</strong></li></ol>



<p>If you decide to extract data manually, it will be time—consuming and cumbersome, leading to a monotonous way of working. Moreover, as documents pile up in your company, it becomes tiring to consolidate this information into what is relevant to your business. This is why most organizations look for more innovative methods of data extraction.&nbsp;</p>



<ol class="wp-block-list" start="2"><li><strong>Automated data extraction can be customized</strong></li></ol>



<p>The most powerful systems in the world that run on machine learning and artificial intelligence understand documents the same way as humans. First, organizations can teach the data extraction software they use to extract only the required data. Then, you can make the software work in real—time to pull data whenever new data comes in.&nbsp;</p>



<ol class="wp-block-list" start="3"><li><strong>Automated data extraction is simple</strong></li></ol>



<p>Using automated data extraction software is easier than it sounds. With a user—friendly interface, you can easily find and extract what you need. You need not have coding experience before using any data extracting software.&nbsp;</p>



<p>Most interfaces have a point and click system, making it easier for the user to navigate. With an appropriate data extraction plan, you can decide your data needs and comfort level on the interface.&nbsp;</p>



<h2 class="wp-block-heading"><strong>How has artificial intelligence become helpful for data extraction?</strong></h2>



<p>The very vision of artificial intelligence was to create machines that mimic humans in their functions and abilities. However, language is considered the most important feature in humans, and artificial intelligence has advanced in understanding that. Therefore, AI has integrated language into Natural Language Processing(NLP).&nbsp;</p>



<p>NLP comprises natural language understanding(human to machine) and natural language generation(machine to human). The surge in unstructured content in text, videos, and more has led to an increase in NLP demand. It can extract valuable data from text content such as feedback, customer surveys, etc.</p>



<h2 class="wp-block-heading"><strong>Which AI models can be used to extract data?</strong></h2>



<figure class="wp-block-image"><img decoding="async" src="https://lh6.googleusercontent.com/RBlYSTLMAl9gGpEM_hCdS-maBM4sEnXkukXhv_uvino6FYRTEFMx2Q2F6OCQfniczOOwT2HUVq2tqVrMEkDXYo9dKg0xsnHwGQeIfQj5GQQ3tkEZbhiQGvY0UmzgzpCRn3DCv0x0-tKwH5ZAbg" alt="ai models"/></figure>



<p><a href="https://www.lboro.ac.uk/media-centre/press-releases/2022/march/ai-model-speed-up-document-analysis/" rel="noopener noreferrer"><em>Source</em></a></p>



<p>The following five AI techniques are commonly used for data extraction:</p>



<ol class="wp-block-list"><li><strong>Named Entity Recognition</strong></li></ol>



<p>The most common and helpful model for data extraction is Named Entity Recognition(NER). The NER model can find different entities present in the text, such as locations, persons, dates, etc. simply put, NER extracts valuable data and adds meaning to the text document.&nbsp;</p>



<p>The different types of NER systems are:</p>



<ul class="wp-block-list"><li><strong>Dictionary—based NER systems</strong>: In this NER approach, there is a dictionary containing existing vocabulary. The basic string matching algorithms then check if the given text matches with the entity as mentioned in the dictionary. The only limitation of this approach is that the dictionary must be updated repeatedly.&nbsp;</li></ul>



<ul class="wp-block-list"><li><strong>Rule—based systems</strong>: In this model, there are a few pre—defined rules set for data extraction. Pattern—based rules and context—based rules are the two common types used. The former depends on the morphological way of words used, whereas the latter relies on the context of the term used in the document.&nbsp;</li></ul>



<ul class="wp-block-list"><li><strong>Machine learning based systems</strong>: Systems related to <a href="https://levity.ai/blog/machine-learning-for-business-beginners-guide" class="link-red">machine learning for business</a> use statistical—based models to detect entity names. A feature—based representation of the given data is created. The limitations of the other two models are erased as this approach can recognize an entity even with a spelling variation.&nbsp;</li></ul>



<p>There are two phases of an ML—based solution for NER. The first phase involves training the ML model on the annotated documents. In the next stage, the trained model can be used to annotate raw documents. The time taken to train the model will depend upon the complexity of the built model.&nbsp;</p>



<ul class="wp-block-list"><li><strong>Deep Learning approach:</strong> Deep Learning systems are used more than ever as they create state—of—the—art systems for NER. The DL technique works better than the other three models as the input data is mapped to a non—linear representation. Additionally, time and resources are saved as feature engineering isn’t required.&nbsp;</li></ul>



<p>The everyday use cases of the NER model can be seen in:</p>



<ul class="wp-block-list"><li><strong>Customer Support</strong>: Every company has a customer support team to handle customer requests and complaints. These requests may be about the installation, maintenance, and other queries regarding the product. NER identifies and understands demands and automatically sends them to the respective support desk.&nbsp;</li><li><strong>Filtering resumes</strong>: So many resumes come in for a particular job. However, the recruiting team doesn’t have the time to go through each application. The NER model does the job of filtering out resumes through an automated system.&nbsp;</li></ul>



<p>This works when you mention specific vital skills needed for the specified role. The NER model is then trained to find the particular skill—sets from the entities. If your resume meets the requirements, it moves to the next stage.</p>



<ul class="wp-block-list"><li><strong>Electronic Healthcare Data</strong>: NER model can be used to build a robust medical healthcare system. It can identify the symptoms from the patients’ data and diagnose the disease or the health issue they’re facing. Furthermore, their treatment can be rightly decided based on the correlated data.&nbsp;</li></ul>



<ol class="wp-block-list" start="2"><li><strong>Sentiment Analysis</strong></li></ol>



<p>Another NLP technique that is widely used is sentiment analysis. This method is most useful in cases where customer surveys, reviews, and social media comments are involved. You can understand people’s sentiments based on their opinions and feedback.&nbsp;</p>



<p>The simplest method to understand the sentiment is a 3—point scale: positive/neutral/negative. For an in—depth analysis, you can add more categories and measure the feedback in a numeric score. This method will be helpful for brands as they can understand:</p>



<ul class="wp-block-list"><li>Critical aspects of a brand’s product or service that customers care about</li><li>The reactions and the underlying intentions of the users concerning those aspects</li></ul>



<ol class="wp-block-list" start="3"><li><strong>Text Summarization</strong></li></ol>



<figure class="wp-block-image"><img decoding="async" src="https://lh4.googleusercontent.com/cRCAhgrNcWGcx49RfhBO3rXZO0jhMl3hmz0RzGKgB2LwUWLtCFwoA0lSf-qzXZJrAY35ndyKmznI9SX2IrPpWQWEcYFLigtA2vOjx5SykaYWa6j3VFbQnYa8M0TCa7CfsCrc5YrtO-wqMMYwaQ" alt="ai models"/></figure>



<p><a href="https://medium.com/luisfredgs/automatic-text-summarization-with-machine-learning-an-overview-68ded5717a25" rel="noopener noreferrer"><em>Source</em></a></p>



<p>As the name suggests, Text Summarization is an NLP technique that condenses large chunks of text. It is used commonly in news articles and research articles. By automating this task, you not only reduce the initial size of the text but preserve the key elements and meaning of the text.&nbsp;</p>



<p>There are two common approaches to text summarization. The extraction approach creates a summary by extracting parts from the text. The abstraction approach creates a summary by generating fresh content that retains the original text&#8217;s meaning.&nbsp;</p>



<ol class="wp-block-list" start="4"><li><strong>Aspect Mining</strong></li></ol>



<p>Aspect Mining identifies crosscutting concerns in the text. It provides insights enabling the classification of different aspects of the content, such as news and social media. When combined with sentiment analysis, it extracts the complete intent of the text.&nbsp;</p>



<p>Aspect mining can be beneficial in opinion mining, where you can determine the central aspect of each review. In addition, this extracted data can be helpful for marketing and sales purposes.&nbsp;</p>



<ol class="wp-block-list" start="5"><li><strong>Topic Modeling</strong></li></ol>



<p>Topic Modelling is a complicated NLP method that can identify natural topics in the text. The benefit of using topic modeling is that it is an unsupervised technique that doesn&#8217;t require model training or a labeled training dataset.</p>



<p>Latent Dirichlet Allocation(LDA) is an example of the topic model where the text of a document is organized into a particular topic. It builds a topic per document and then distributes words per topic model. These models are known as Dirichlet distributions.&nbsp;</p>



<h3 class="wp-block-heading"><strong>In closing</strong></h3>



<p>Establishing an AI—based data extraction system within your business may seem complicated with all the technical requirements. However, the five NLP models mentioned above are easy to set up and use. You don’t need any prior coding experience to get these software models up and running in your business.</p>
<p>The post <a href="https://www.restapiexample.com/misc/five-ai-models-for-data-extraction-that-you-need-to-consider-for-your-business/">Five AI Models for Data Extraction That You Need to Consider for Your Business</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>How Significant is Usability Testing for Successful API Design?</title>
		<link>https://www.restapiexample.com/rest-api-documentation/how-significant-is-usability-testing-for-successful-api-design/</link>
		
		<dc:creator><![CDATA[RestAPIExample Team]]></dc:creator>
		<pubDate>Mon, 11 Apr 2022 14:04:11 +0000</pubDate>
				<category><![CDATA[Misc Rest Api Information]]></category>
		<guid isPermaLink="false">https://www.restapiexample.com/?p=1052</guid>

					<description><![CDATA[<p>As you start writing the specific steps users need to undertake to achieve their goals, you are putting yourself in their shoes and workflows. If you have to go through many challenges while at it, such as inconsistent parameters, the reason might be that your API&#8217;s usability is not good.  So, precisely what is one [&#8230;]</p>
<p>The post <a href="https://www.restapiexample.com/rest-api-documentation/how-significant-is-usability-testing-for-successful-api-design/">How Significant is Usability Testing for Successful API Design?</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>As you start writing the specific steps users need to undertake to achieve their goals, you are putting yourself in their shoes and workflows. If you have to go through many challenges while at it, such as inconsistent parameters, the reason might be that your API&#8217;s usability is not good. </p>



<span id="more-1052"></span>



<p>So, precisely what is one of the initial signs that your API might not be what you want? Well, it&#8217;s accessed based on how hard technical writers find it to write the documentation about your API. If they do, then things may not be your way! &nbsp;</p>



<p>After all, technical writers are responsible for providing the proper feedback on usability, especially after you step into the user tasks in-depth, but there are more things to discuss. That&#8217;s why in this article, we will find out how vital usability testing is for a successful API design.&nbsp;</p>



<h2 class="wp-block-heading"><strong>How important is usability testing to create a successful API design?&nbsp;</strong></h2>



<h3 class="wp-block-heading"><strong>Usability testing is directly related&nbsp;</strong></h3>



<p>Initially, we need to identify how<a href="https://maze.co/guides/usability-testing/" class="link-red"> usability testing</a> is directly related to a successful API design. In other words, usability refers to how easily users can accomplish their tasks while using a tool. In order to evaluate usability, you need to identify what kind of tasks users want to perform&nbsp;</p>



<p>with the API.&nbsp;</p>



<h3 class="wp-block-heading"><strong>The timing&nbsp;</strong></h3>



<figure class="wp-block-image"><img decoding="async" src="https://lh3.googleusercontent.com/0aZKIAZOaXZPwL8KGlE38Z7wkgIHhSxWGDc0jS-rvKCYpdbFiugF2Qlcm6rQqMAEq-L-hxCV_nH9nvKBtRR2E1CJfDCV9QENbTpSMGNXJbtkCLacxORbjwiGUvKFFz8o3N7tCzlq" alt=""/></figure>



<p>The best time to start conducting usability testing is at the beginning of a project, so do so now if you still haven&#8217;t done that. Moreover, a mistake you should avoid making is doing usability testing for your APIs right before the release date. Instead, do it early on and gather feedback early on in the<a href="https://haltian.com/resource/new-product-development-cycle-infographic/#:~:text=Product%20development%20life%20cycle%20(PDLC,growth%2C%20maturity%2C%20and%20decline." rel="noopener noreferrer" class="link-red"> development lifecycle</a> to make any required changes to the product sooner than never. &nbsp;</p>



<p>So, after you design your API, it&#8217;s time to conduct your usability testing. You can easily generate Mock APIs with many modern tools such as<a href="https://www.openapis.org/" rel="noopener noreferrer" class="link-red"> OpenAPI</a> that can be used for your usability testing. If you want to develop first and don&#8217;t have mock APIs, you can consider performing usability testing <strong>after the development stage.&nbsp;</strong></p>



<h3 class="wp-block-heading"><strong>Users</strong></h3>



<p>The best thing you can do is to identify the types of skills and roles your customers have and create<a href="https://xd.adobe.com/ideas/process/user-research/putting-personas-to-work-in-ux-design/" rel="noopener noreferrer" class="link-red"> user personas</a> from it after. By doing this, you are getting a customer&#8217;s perspective on your APIs and finding the right participants to conduct your usability testing.&nbsp;&nbsp;</p>



<p>However, what also matters is the type of developers you have to integrate your<a href="https://www.restapiexample.com/build-rest-api/restful-api-with-express-part-ii/" class="link-red"> APIs</a> and start developing a new API. Therefore, you need to pay special attention to the people you wish to hire for this part as it&#8217;s just as important.&nbsp;</p>



<h3 class="wp-block-heading"><strong>Evaluation&nbsp;</strong></h3>



<figure class="wp-block-image"><img decoding="async" src="https://lh4.googleusercontent.com/1fDYf3rKXDP3isgtBulS6-iTs2bQWBAhmK5zb6KSJMJ66iYSlJwIsN16WIfAgw3FklyZFwz3bwK5ugmqLeevlqWmHuQDYiNok9PytrY0DSyK9NxBjuA-7W_74q_UNKt75WggDEBP" alt=""/></figure>



<p>If your API design has inconsistent designs, it most likely will make the interface harder to understand and use. In other words, an API should be consistent to the extent that developers can predict. However, in terms of evaluating API usability, there are some things you need to cover.&nbsp;</p>



<h3 class="wp-block-heading"><strong>Have straightforward endpoints&nbsp;</strong></h3>



<p>When you look at an endpoint, will you have any idea what it returns? You always keep in mind the tasks that users want to accomplish with the API and the terms they use to describe the tasks they wish to achieve.&nbsp;</p>



<p>Moreover, if you could draw a line between the user&#8217;s tasks and the endpoint they need to accomplish a task, your endpoints are straightforward. However, if you can&#8217;t do this, users might have difficulties.&nbsp;</p>



<h3 class="wp-block-heading"><strong>Consistency in endpoint patterns&nbsp;</strong></h3>



<p>Ask yourself if the endpoints are following a consistent pattern or not. Take a second to look at them and see if they follow a consistent format. Does it look like different teams working on other API parts without communication? This isn&#8217;t quite hard to distinguish for technical writers.&nbsp;</p>



<p>For instance, some issues you might run into with inconsistency is an API working for one device type may not work for the other one. As a result, names may look inconsistent, and it may seem quite apparent to others that the same team didn&#8217;t work on the APIs. Inconsistency won&#8217;t only ruin one thing, it&#8217;ll ruin many things and not allow users to find the ‘<a href="https://uxdesign.cc/what-is-an-aha-moment-e32cba636733#:~:text=Well%2C%20an%20Aha%20moment%20is,from%20them%20to%20said%20product." rel="noopener noreferrer" class="link-red"><strong>aha moment</strong></a>’ from the products and services they are using.&nbsp;</p>



<h3 class="wp-block-heading"><strong>Real-world testing&nbsp;</strong></h3>



<p>Consider how the API will be used in the real world and how that’ll drive new design choices. Of course, product owners will always think that they know precisely how a product should be, but consumers are the ones who make the decisions here. As a result, we can say that any developer who conducted a usability session that didn’t work out has been humbled right after.&nbsp;</p>



<p>This is the same story with an API and users. Think about what details consumers need and how they may be used. Also, pay attention to your environment. For example, can the API be used with an internal app across a<a href="https://www.techtarget.com/searchnetworking/definition/local-area-network-LAN#:~:text=A%20local%20area%20network%20(LAN,in%20a%20corporation's%20central%20office." rel="noopener noreferrer" class="link-red"> local area network</a> (LAN) or a limited bandwidth on a mobile app?&nbsp;</p>



<h3 class="wp-block-heading"><strong>Some other questions to answer include: </strong></h3>



<ul class="wp-block-list"><li>What is the response time?&nbsp;</li><li>Is the current response time suitable for the use case?&nbsp;</li><li>How many customers need to be served?&nbsp;</li><li>Is the API private or public?&nbsp;</li><li>Does the data require any special handling?&nbsp;</li></ul>



<h3 class="wp-block-heading"><strong>Motivating the issue&nbsp;</strong></h3>



<figure class="wp-block-image"><img decoding="async" src="https://lh3.googleusercontent.com/u2FomJz-uctqqBMMCTjm9wtrt9rGsQWHoZuNqLLfsU6LyFxnVE_8li4j2lKuoPFaelPO2XPmHQiv4oBQmSBc84mQF-17L-zngCfpOrfk87m3T5th7mrsCH_FNeWhN333gUvXRUH8" alt=""/></figure>



<p>API design may be complex because of the many quality attributes for APIs to be evaluated by stakeholders. The two essential qualities of an API are its <strong>usability</strong> and its <strong>power</strong>.&nbsp;</p>



<p>So overall, usability shows how easy an API is to learn and how productive developers are when they use it. Moreover, it also means how simple it is and how well the API prevents errors. On the other hand, power is more of the API’s expressiveness and extensibility.&nbsp;</p>



<p>Even though an API has two essential qualities, usability mainly affects it. Something else to know is that the design of an API requires hundreds of design decisions on different levels, and let’s be honest, all of them can affect its usability. These can be anything from the global issue or overall API architecture, what kind of design patterns will be used, and how the functionality will be organized.&nbsp;&nbsp;</p>



<h3 class="wp-block-heading"><strong>Versioning&nbsp;</strong></h3>



<p>Yes, versioning. It’s an excellent way to add new features to the API or even change them without breaking any experiences for your users. Furthermore, it’s much more cost-effective than making changes and fixes late in the development phase and, even worse, making them when the API is already in the real world!&nbsp;</p>



<p>These issues can be avoided earlier in the development phase, and specific changes are much less problematic than others. Here are some things to consider:&nbsp;</p>



<ul class="wp-block-list"><li>Adding new data can be an okay choice, but it’ll depend on the data format</li><li>Removing existing data is never a good idea and removing an existing endpoint isn’t either&nbsp;</li><li>Major problems will arise when you choose to change existing data behavior and endpoints&nbsp;</li></ul>



<p>After all, ask yourself the following questions:&nbsp;</p>



<ul class="wp-block-list"><li>How many versions will you support?&nbsp;</li><li>How will you test different versions?&nbsp;</li><li>How long will you be supporting these versions?&nbsp;</li></ul>



<p>Versions directly affect the transparency in your quality and testing. You can consider using the<a href="https://whatis.techtarget.com/definition/canary-canary-testing" rel="noopener noreferrer" class="link-red"> canary concept</a> where a slow-increasing set of clients are directed to the most recent changes and ensure that these sets of changes are acceptable. Alternatively, you can also consider A/B API testing, which includes deploying a performance tweak to a group of clients to validate and measure improvements.&nbsp;</p>



<h3 class="wp-block-heading"><strong>API usability testing in a few steps&nbsp;</strong></h3>



<p>In order to learn as much as we can from our tests, we need to prepare. Here are a few simple steps you can undertake to get the most out of usability testing:&nbsp;</p>



<ul class="wp-block-list"><li>Define a task which you are supposed to test</li><li>Give as much information as needed to begin the assigned task&nbsp;</li><li>Find out how you can observe the user when they are using your API</li><li>Ensure that the user is speaking loud enough when testing your product and explains in-depth what they think about your product</li><li>Allow questions to be asked in case your users get stuck at some point&nbsp;</li><li>Create a detailed report based on test results&nbsp;</li><li>Derive tasks from your observations&nbsp;</li><li>Share your observations with your team&nbsp;</li></ul>



<h2 class="wp-block-heading"><strong>Wrapping it up&nbsp;</strong></h2>



<p>Well, that’s all in this article. These were our tips and tricks on how usability testing directly affects a successful API design. Moreover, you must address any issues that may arise with your API design early in the development phase since it will create problems addressing them when the product is released or just before it releases. &nbsp;</p>



<p>Usability API design testing goes through hundreds of designs to find which one is the ideal one. It’s your job to ensure that you choose the one that satisfies your customers out of all these designs!</p>
<p>The post <a href="https://www.restapiexample.com/rest-api-documentation/how-significant-is-usability-testing-for-successful-api-design/">How Significant is Usability Testing for Successful API Design?</a> appeared first on <a href="https://www.restapiexample.com">Rest Api Example</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>