npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@youth10313/youth-apis

v2.4.1

Published

ahmed alhasan's youth APIs we've created simple package for you to use our APIs in your projects easily. but we prefer you to read our [API Documentation](https://developers.ahmedalhasan.com/). also do not to check [Youth Club](https://ahmedalhasan.club)

Downloads

8

Readme

Youth APIs

ahmed alhasan's youth APIs.

we've created simple package for you to use our APIs in your projects easily. but we prefer you to read our API Documention. also do not forget to check Youth Club

How To Use?

import YouthServers from "@youth10313/youth-apis";

declare page;
const Search = YouthServers.Data.Core("Ahmed", "en", page);

Search.onChange(state => {
    // loading state change
})

Search.onError(err => {
    // handle Errors
})

Search.onComplete(response => {
    // do something with response
})

Search.subscribe(); // this will make the request.
Search.abort(); // this will abort the request.

Advance usage

we've provided some functions that helps you to fetch data easier.

1. Convert data with Convert function before onComplete Event.

2. You can briefing the data that you fetching from the server to make request size smaller.

3. You can pass new params into subscribe function. any thing will be override.

const posts = YouthServers.Data.Feeds.Blog.posts.fetch("en", { category: '__categoryId' }, '__AuthenticationToken', 1, 13, '');

posts.onError(error => {
    // any handling error code
    alert('We have an error.' + error.response?.status ? `Error Code is ${error.response.status}` : `No Internet Connection`);
})

posts.onChange(state => {
    const spinner = document.getElementById('spinner');
    spinner.style.display = state ? 'block' : 'none';
})

// here you can convert the whole data fetched from server.
posts.Convert(res => {
    res.items = res.items.map(item => `
        <h4>${item.title}</h4>
        <p>${item.description}</p>
        <a href='/path/to/${item.latinTitle}'>Read More</a>
    `);
    return res;
})

// now this event will pass converted data to your function.
posts.onComplete(res => {
    const content = document.getElementById('content');
    content?.innerHTML = '';
    res.items.forEach(item => content?.innerHTML += item)
})

function startRequest(category) {
    posts.subscribe(
        ['title', 'latinTitle', 'description'], // the server response will only contains these fields.
        { params: { category } } // you can override headers, params and any argument you passed in fetch function
        // the cid is the id you passed in fetchOne and id is the Id you want to replace.
        )
}


const cancelButton = document.getElementById('cancel-button');
cancelButton?.addEventListener('click', posts.abort) // so the user can cancel the fetching request.

const refreshButton = document.getElementById('refresh-button');
refreshButton?.addEventListener('click', () => startRequest('__selected_category_id__'))


document.addEventListener('load', () => startRequest(''))

it is so easy to use. for example if you working on an react project, your component sould be liek this:

import YouthServers from "@youth10313/youth-apis";
import i18next from "i18next";
import { useEffect } from "react";
import { useState } from "react"
import { useDispatch, useSelector } from "react-redux";

export const AnsarImamMahdi = () => {
    const dispatch = useDispatch();
    const { ansar } = useSelector(state => state.main);
    const [loading, setLoading] = useState(false);
    const [error, setError] = useState(null);
    const api = YouthServers.Data.Feeds.Main.Ansars.fetch(i18next.language);
    api.onChange(setLoading);
    api.onError(setError);
    api.onComplete(data => {
        dispatch({ type: "FETCH_ANSAR", payload: data });
    })

    useEffect(() => {
        api.subscribe();
        return () => api.abort();
    })
    return <div className="d-flex">
        {
            loading ? <div className="spinner" /> :

                ansar.map(person =>
                    <div className="card" key={person._id}>
                        <h4>{person.title}</h4>
                        <p>{person.desciption}</p>

                        <a href={person.url}>Read More</a>
                    </div>
                )
        }
    </div>
} 

when you want to fetch data from an api that has pagination or any kind of filters (read: API Documention) you can pass the queries in two ways.

  1. pass them through original args:
YouthServers.Data.Feeds.Blog.posts.fetch(
   locale: string,
   querystring: any = {},
   Authorization = '',
   page?: number,
   perPage?: number,
   search?: string,
   sort_by?: string,
   sort_order?: 'ASC' | 'DESC',
   date_start?: Date,
   date_end?: Date,
   category?: string | string[]
)
  1. pass them through querystring:
YouthServers.Data.Feeds.Blog.posts.fetch(
   "",
   querystring: any = {
       locale: "fa",
       page: 1,
       perPage: 100,
       ...
   },
   Authorization = ''
)

Also you can mix these two ways.

HTTP Proxy

if you want to access the API through a proxy, so you can set the proxies in .env file;

REACT_APP_AUTH_API_PROXY="http://url.proxy/"
REACT_APP_DATA_API_PROXY="http://url.proxy/"
REACT_APP_CLOUD_API_PROXY="http://url.proxy/"
REACT_APP_OFFICIAL_API_PROXY="http://url.proxy/"

contact me at Telegram if you have any questions: Youth10313

Do not forget to donate us:

via USDT (TRC20): TLpGCNrfXRuQz93kpzKSvLDysNUdCPBw1g